summaryrefslogtreecommitdiff
path: root/deps/v8/src/d8/d8.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/d8/d8.cc')
-rw-r--r--deps/v8/src/d8/d8.cc217
1 files changed, 134 insertions, 83 deletions
diff --git a/deps/v8/src/d8/d8.cc b/deps/v8/src/d8/d8.cc
index d5b4600ad6..8c9a4c3ae6 100644
--- a/deps/v8/src/d8/d8.cc
+++ b/deps/v8/src/d8/d8.cc
@@ -32,6 +32,7 @@
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/platform/wrappers.h"
+#include "src/base/sanitizer/msan.h"
#include "src/base/sys-info.h"
#include "src/d8/d8-console.h"
#include "src/d8/d8-platforms.h"
@@ -53,7 +54,6 @@
#include "src/parsing/parsing.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/profiler/profile-generator.h"
-#include "src/sanitizer/msan.h"
#include "src/snapshot/snapshot.h"
#include "src/tasks/cancelable-task.h"
#include "src/trap-handler/trap-handler.h"
@@ -333,11 +333,6 @@ class MultiMappedAllocator : public ArrayBufferAllocatorBase {
v8::Platform* g_default_platform;
std::unique_ptr<v8::Platform> g_platform;
-static Local<Value> Throw(Isolate* isolate, const char* message) {
- return isolate->ThrowException(v8::Exception::Error(
- String::NewFromUtf8(isolate, message).ToLocalChecked()));
-}
-
static MaybeLocal<Value> TryGetValue(v8::Isolate* isolate,
Local<Context> context,
Local<v8::Object> object,
@@ -355,13 +350,13 @@ static Local<Value> GetValue(v8::Isolate* isolate, Local<Context> context,
std::shared_ptr<Worker> GetWorkerFromInternalField(Isolate* isolate,
Local<Object> object) {
if (object->InternalFieldCount() != 1) {
- Throw(isolate, "this is not a Worker");
+ isolate->ThrowError("this is not a Worker");
return nullptr;
}
i::Handle<i::Object> handle = Utils::OpenHandle(*object->GetInternalField(0));
if (handle->IsSmi()) {
- Throw(isolate, "Worker is defunct because main thread is terminating");
+ isolate->ThrowError("Worker is defunct because main thread is terminating");
return nullptr;
}
auto managed = i::Handle<i::Managed<Worker>>::cast(handle);
@@ -696,6 +691,12 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
Local<Context> context(isolate->GetCurrentContext());
ScriptOrigin origin(isolate, name);
+ for (int i = 1; i < options.repeat_compile; ++i) {
+ HandleScope handle_scope(isolate);
+ if (CompileString<Script>(isolate, context, source, origin).IsEmpty()) {
+ return false;
+ }
+ }
Local<Script> script;
if (!CompileString<Script>(isolate, context, source, origin)
.ToLocal(&script)) {
@@ -710,6 +711,9 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
StoreInCodeCache(isolate, source, cached_data);
delete cached_data;
}
+ if (options.compile_only) {
+ return true;
+ }
maybe_result = script->Run(realm);
if (options.code_cache_options ==
ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) {
@@ -728,7 +732,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
if (options.web_snapshot_config) {
std::vector<std::string> exports;
if (!ReadLines(options.web_snapshot_config, exports)) {
- Throw(isolate, "Web snapshots: unable to read config");
+ isolate->ThrowError("Web snapshots: unable to read config");
CHECK(try_catch.HasCaught());
ReportException(isolate, &try_catch);
return false;
@@ -965,7 +969,8 @@ MaybeLocal<Module> Shell::FetchModuleTree(Local<Module> referrer,
CHECK(specifier_it != d->module_to_specifier_map.end());
msg += "\n imported by " + specifier_it->second;
}
- Throw(isolate, msg.c_str());
+ isolate->ThrowError(
+ v8::String::NewFromUtf8(isolate, msg.c_str()).ToLocalChecked());
return MaybeLocal<Module>();
}
ScriptOrigin origin(
@@ -1024,7 +1029,7 @@ MaybeLocal<Module> Shell::FetchModuleTree(Local<Module> referrer,
context, import_assertions, true);
if (request_module_type == ModuleType::kInvalid) {
- Throw(isolate, "Invalid module type was asserted");
+ isolate->ThrowError("Invalid module type was asserted");
return MaybeLocal<Module>();
}
@@ -1211,7 +1216,7 @@ void Shell::DoHostImportModuleDynamically(void* import_data) {
try_catch.SetVerbose(true);
if (module_type == ModuleType::kInvalid) {
- Throw(isolate, "Invalid module type was asserted");
+ isolate->ThrowError("Invalid module type was asserted");
CHECK(try_catch.HasCaught());
resolver->Reject(realm, try_catch.Exception()).ToChecked();
return;
@@ -1358,7 +1363,7 @@ bool Shell::ExecuteWebSnapshot(Isolate* isolate, const char* file_name) {
std::unique_ptr<uint8_t[]> snapshot_data(
reinterpret_cast<uint8_t*>(ReadChars(absolute_path.c_str(), &length)));
if (length == 0) {
- Throw(isolate, "Error reading the web snapshot");
+ isolate->ThrowError("Error reading the web snapshot");
DCHECK(try_catch.HasCaught());
ReportException(isolate, &try_catch);
return false;
@@ -1468,6 +1473,14 @@ void PerIsolateData::DeleteDynamicImportData(DynamicImportData* data) {
delete data;
}
+Local<FunctionTemplate> PerIsolateData::GetTestApiObjectCtor() const {
+ return test_api_object_ctor_.Get(isolate_);
+}
+
+void PerIsolateData::SetTestApiObjectCtor(Local<FunctionTemplate> ctor) {
+ test_api_object_ctor_.Reset(isolate_, ctor);
+}
+
PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) {
data_->realm_count_ = 1;
data_->realm_current_ = 0;
@@ -1500,14 +1513,14 @@ int PerIsolateData::RealmFind(Local<Context> context) {
int PerIsolateData::RealmIndexOrThrow(
const v8::FunctionCallbackInfo<v8::Value>& args, int arg_offset) {
if (args.Length() < arg_offset || !args[arg_offset]->IsNumber()) {
- Throw(args.GetIsolate(), "Invalid argument");
+ args.GetIsolate()->ThrowError("Invalid argument");
return -1;
}
int index = args[arg_offset]
->Int32Value(args.GetIsolate()->GetCurrentContext())
.FromMaybe(-1);
if (index < 0 || index >= realm_count_ || realms_[index].IsEmpty()) {
- Throw(args.GetIsolate(), "Invalid realm index");
+ args.GetIsolate()->ThrowError("Invalid realm index");
return -1;
}
return index;
@@ -1565,7 +1578,7 @@ void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (args.Length() < 1 || !args[0]->IsObject()) {
- Throw(args.GetIsolate(), "Invalid argument");
+ args.GetIsolate()->ThrowError("Invalid argument");
return;
}
Local<Object> object =
@@ -1577,7 +1590,7 @@ void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
Local<Context> creation_context;
if (!object->GetCreationContext().ToLocal(&creation_context)) {
- Throw(args.GetIsolate(), "object doesn't have creation context");
+ args.GetIsolate()->ThrowError("object doesn't have creation context");
return;
}
int index = data->RealmFind(creation_context);
@@ -1661,7 +1674,7 @@ void Shell::RealmNavigate(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (index == -1) return;
if (index == 0 || index == data->realm_current_ ||
index == data->realm_switch_) {
- Throw(args.GetIsolate(), "Invalid realm index");
+ args.GetIsolate()->ThrowError("Invalid realm index");
return;
}
@@ -1690,7 +1703,7 @@ void Shell::RealmDetachGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (index == -1) return;
if (index == 0 || index == data->realm_current_ ||
index == data->realm_switch_) {
- Throw(args.GetIsolate(), "Invalid realm index");
+ args.GetIsolate()->ThrowError("Invalid realm index");
return;
}
@@ -1707,7 +1720,7 @@ void Shell::RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (index == -1) return;
if (index == 0 || index == data->realm_current_ ||
index == data->realm_switch_) {
- Throw(args.GetIsolate(), "Invalid realm index");
+ args.GetIsolate()->ThrowError("Invalid realm index");
return;
}
DisposeRealm(args, index);
@@ -1729,7 +1742,7 @@ void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) {
int index = data->RealmIndexOrThrow(args, 0);
if (index == -1) return;
if (args.Length() < 2 || !args[1]->IsString()) {
- Throw(args.GetIsolate(), "Invalid argument");
+ args.GetIsolate()->ThrowError("Invalid argument");
return;
}
ScriptOrigin origin(isolate,
@@ -1780,18 +1793,18 @@ void Shell::LogGetAndStop(const v8::FunctionCallbackInfo<v8::Value>& args) {
std::string file_name = i_isolate->logger()->file_name();
if (!i::Log::IsLoggingToTemporaryFile(file_name)) {
- Throw(isolate, "Only capturing from temporary files is supported.");
+ isolate->ThrowError("Only capturing from temporary files is supported.");
return;
}
if (!i_isolate->logger()->is_logging()) {
- Throw(isolate, "Logging not enabled.");
+ isolate->ThrowError("Logging not enabled.");
return;
}
std::string raw_log;
FILE* log_file = i_isolate->logger()->TearDownAndGetLogFile();
if (!log_file) {
- Throw(isolate, "Log file does not exist.");
+ isolate->ThrowError("Log file does not exist.");
return;
}
@@ -1800,7 +1813,7 @@ void Shell::LogGetAndStop(const v8::FunctionCallbackInfo<v8::Value>& args) {
base::Fclose(log_file);
if (!exists) {
- Throw(isolate, "Unable to read log file.");
+ isolate->ThrowError("Unable to read log file.");
return;
}
Local<String> result =
@@ -1816,13 +1829,13 @@ void Shell::TestVerifySourcePositions(
Isolate* isolate = args.GetIsolate();
// Check if the argument is a valid function.
if (args.Length() != 1) {
- Throw(isolate, "Expected function as single argument.");
+ isolate->ThrowError("Expected function as single argument.");
return;
}
auto arg_handle = Utils::OpenHandle(*args[0]);
if (!arg_handle->IsHeapObject() || !i::Handle<i::HeapObject>::cast(arg_handle)
->IsJSFunctionOrBoundFunction()) {
- Throw(isolate, "Expected function as single argument.");
+ isolate->ThrowError("Expected function as single argument.");
return;
}
@@ -1839,7 +1852,7 @@ void Shell::TestVerifySourcePositions(
i::Handle<i::JSFunction> function = i::Handle<i::JSFunction>::cast(callable);
if (!function->shared().HasBytecodeArray()) {
- Throw(isolate, "Function has no BytecodeArray attached.");
+ isolate->ThrowError("Function has no BytecodeArray attached.");
return;
}
i::Handle<i::BytecodeArray> bytecodes =
@@ -1865,7 +1878,7 @@ void Shell::TestVerifySourcePositions(
if (has_baseline) {
if (offset_iterator->current_bytecode_offset() !=
bytecode_iterator.current_offset()) {
- Throw(isolate, "Baseline bytecode offset mismatch.");
+ isolate->ThrowError("Baseline bytecode offset mismatch.");
return;
}
// Check that we map every address to this bytecode correctly.
@@ -1877,7 +1890,8 @@ void Shell::TestVerifySourcePositions(
pc_lookup.AdvanceToPCOffset(pc);
if (pc_lookup.current_bytecode_offset() !=
bytecode_iterator.current_offset()) {
- Throw(isolate, "Baseline bytecode offset mismatch for PC lookup.");
+ isolate->ThrowError(
+ "Baseline bytecode offset mismatch for PC lookup.");
return;
}
}
@@ -1885,14 +1899,14 @@ void Shell::TestVerifySourcePositions(
bytecode_iterator.Advance();
if (has_baseline && !bytecode_iterator.done()) {
if (offset_iterator->done()) {
- Throw(isolate, "Missing bytecode(s) in baseline offset mapping.");
+ isolate->ThrowError("Missing bytecode(s) in baseline offset mapping.");
return;
}
offset_iterator->Advance();
}
}
if (has_baseline && !offset_iterator->done()) {
- Throw(isolate, "Excess offsets in baseline offset mapping.");
+ isolate->ThrowError("Excess offsets in baseline offset mapping.");
return;
}
}
@@ -1928,6 +1942,13 @@ void Shell::AsyncHooksTriggerAsyncId(
void Shell::SetPromiseHooks(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
+ if (i::FLAG_correctness_fuzzer_suppressions) {
+ // Make sure we have no pending promises if correctness fuzzing is active.
+ // Due to fast-paths we might have not created all intermediate promises
+ // that aren't spec visible. However, the promise hook might expose them
+ // and cause different output.
+ isolate->PerformMicrotaskCheckpoint();
+ }
Local<Context> context = isolate->GetCurrentContext();
HandleScope handle_scope(isolate);
@@ -1953,7 +1974,7 @@ void WriteToFile(FILE* file, const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<String> str_obj;
if (arg->IsSymbol()) {
- arg = arg.As<Symbol>()->Description();
+ arg = arg.As<Symbol>()->Description(args.GetIsolate());
}
if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
.ToLocal(&str_obj)) {
@@ -1992,7 +2013,7 @@ void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
String::Utf8Value file(args.GetIsolate(), args[0]);
if (*file == nullptr) {
- Throw(args.GetIsolate(), "Error loading file");
+ args.GetIsolate()->ThrowError("Error loading file");
return;
}
if (args.Length() == 2) {
@@ -2004,7 +2025,7 @@ void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
Local<String> source = ReadFile(args.GetIsolate(), *file);
if (source.IsEmpty()) {
- Throw(args.GetIsolate(), "Error loading file");
+ args.GetIsolate()->ThrowError("Error loading file");
return;
}
args.GetReturnValue().Set(source);
@@ -2052,12 +2073,12 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope handle_scope(args.GetIsolate());
String::Utf8Value file(args.GetIsolate(), args[i]);
if (*file == nullptr) {
- Throw(args.GetIsolate(), "Error loading file");
+ args.GetIsolate()->ThrowError("Error loading file");
return;
}
Local<String> source = ReadFile(args.GetIsolate(), *file);
if (source.IsEmpty()) {
- Throw(args.GetIsolate(), "Error loading file");
+ args.GetIsolate()->ThrowError("Error loading file");
return;
}
if (!ExecuteString(
@@ -2066,7 +2087,7 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
kNoPrintResult,
options.quiet_load ? kNoReportExceptions : kReportExceptions,
kNoProcessMessageQueue)) {
- Throw(args.GetIsolate(), "Error executing file");
+ args.GetIsolate()->ThrowError("Error executing file");
return;
}
}
@@ -2129,7 +2150,7 @@ bool FunctionAndArgumentsToString(Local<Function> function,
function->FunctionProtoToString(context);
Local<String> function_string;
if (!maybe_function_string.ToLocal(&function_string)) {
- Throw(isolate, "Failed to convert function to string");
+ isolate->ThrowError("Failed to convert function to string");
return false;
}
*source = String::NewFromUtf8Literal(isolate, "(");
@@ -2138,7 +2159,7 @@ bool FunctionAndArgumentsToString(Local<Function> function,
*source = String::Concat(isolate, *source, middle);
if (!arguments.IsEmpty() && !arguments->IsUndefined()) {
if (!arguments->IsArray()) {
- Throw(isolate, "'arguments' must be an array");
+ isolate->ThrowError("'arguments' must be an array");
return false;
}
Local<String> comma = String::NewFromUtf8Literal(isolate, ",");
@@ -2150,12 +2171,12 @@ bool FunctionAndArgumentsToString(Local<Function> function,
MaybeLocal<Value> maybe_argument = array->Get(context, i);
Local<Value> argument;
if (!maybe_argument.ToLocal(&argument)) {
- Throw(isolate, "Failed to get argument");
+ isolate->ThrowError("Failed to get argument");
return false;
}
Local<String> argument_string;
if (!JSON::Stringify(context, argument).ToLocal(&argument_string)) {
- Throw(isolate, "Failed to convert argument to string");
+ isolate->ThrowError("Failed to convert argument to string");
return false;
}
*source = String::Concat(isolate, *source, argument_string);
@@ -2170,7 +2191,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
HandleScope handle_scope(isolate);
if (args.Length() < 1 || (!args[0]->IsString() && !args[0]->IsFunction())) {
- Throw(isolate, "1st argument must be a string or a function");
+ isolate->ThrowError("1st argument must be a string or a function");
return;
}
@@ -2184,7 +2205,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<Value> arguments;
ReadWorkerTypeAndArguments(args, &worker_type, &arguments);
if (worker_type != WorkerType::kFunction) {
- Throw(isolate, "Invalid or missing worker type");
+ isolate->ThrowError("Invalid or missing worker type");
return;
}
@@ -2203,7 +2224,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
load_from_file = false;
} else if (worker_type != WorkerType::kNone &&
worker_type != WorkerType::kClassic) {
- Throw(isolate, "Invalid worker type");
+ isolate->ThrowError("Invalid worker type");
return;
}
@@ -2211,7 +2232,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
String::Utf8Value filename(isolate, args[0]);
source = ReadFile(isolate, *filename);
if (source.IsEmpty()) {
- Throw(args.GetIsolate(), "Error loading worker script");
+ args.GetIsolate()->ThrowError("Error loading worker script");
return;
}
} else {
@@ -2220,7 +2241,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
if (!args.IsConstructCall()) {
- Throw(isolate, "Worker must be constructed with new");
+ isolate->ThrowError("Worker must be constructed with new");
return;
}
@@ -2237,7 +2258,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
String::Utf8Value script(isolate, source);
if (!*script) {
- Throw(isolate, "Can't get worker script");
+ isolate->ThrowError("Can't get worker script");
return;
}
@@ -2251,7 +2272,7 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
i_isolate, kWorkerSizeEstimate, worker);
args.Holder()->SetInternalField(0, Utils::ToLocal(managed));
if (!Worker::StartWorkerThread(std::move(worker))) {
- Throw(isolate, "Can't start thread");
+ isolate->ThrowError("Can't start thread");
return;
}
}
@@ -2262,7 +2283,7 @@ void Shell::WorkerPostMessage(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope handle_scope(isolate);
if (args.Length() < 1) {
- Throw(isolate, "Invalid argument");
+ isolate->ThrowError("Invalid argument");
return;
}
@@ -2571,6 +2592,33 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) {
return result.ToLocalChecked().As<String>();
}
+void Shell::NodeTypeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Isolate* isolate = args.GetIsolate();
+ args.GetReturnValue().Set(v8::Number::New(isolate, 1));
+}
+
+Local<FunctionTemplate> Shell::CreateNodeTemplates(Isolate* isolate) {
+ Local<FunctionTemplate> node = FunctionTemplate::New(isolate);
+ Local<ObjectTemplate> proto_template = node->PrototypeTemplate();
+ Local<Signature> signature = v8::Signature::New(isolate, node);
+ Local<FunctionTemplate> nodeType = FunctionTemplate::New(
+ isolate, NodeTypeCallback, Local<Value>(), signature);
+ nodeType->SetAcceptAnyReceiver(false);
+ proto_template->SetAccessorProperty(
+ String::NewFromUtf8Literal(isolate, "nodeType"), nodeType);
+
+ Local<FunctionTemplate> element = FunctionTemplate::New(isolate);
+ element->Inherit(node);
+
+ Local<FunctionTemplate> html_element = FunctionTemplate::New(isolate);
+ html_element->Inherit(element);
+
+ Local<FunctionTemplate> div_element = FunctionTemplate::New(isolate);
+ div_element->Inherit(html_element);
+
+ return div_element;
+}
+
Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
global_template->Set(Symbol::GetToStringTag(isolate),
@@ -2602,6 +2650,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
global_template->Set(isolate, "performance",
Shell::CreatePerformanceTemplate(isolate));
global_template->Set(isolate, "Worker", Shell::CreateWorkerTemplate(isolate));
+
// Prevent fuzzers from creating side effects.
if (!i::FLAG_fuzzing) {
global_template->Set(isolate, "os", Shell::CreateOSTemplate(isolate));
@@ -2730,19 +2779,29 @@ Local<ObjectTemplate> Shell::CreateD8Template(Isolate* isolate) {
FunctionTemplate::New(isolate, LogGetAndStop));
d8_template->Set(isolate, "log", log_template);
+
+ Local<ObjectTemplate> dom_template = ObjectTemplate::New(isolate);
+ dom_template->Set(isolate, "Div", Shell::CreateNodeTemplates(isolate));
+ d8_template->Set(isolate, "dom", dom_template);
}
{
Local<ObjectTemplate> test_template = ObjectTemplate::New(isolate);
- test_template->Set(
- isolate, "verifySourcePositions",
- FunctionTemplate::New(isolate, TestVerifySourcePositions));
+ // For different runs of correctness fuzzing the bytecode of a function
+ // might get flushed, resulting in spurious errors.
+ if (!i::FLAG_correctness_fuzzer_suppressions) {
+ test_template->Set(
+ isolate, "verifySourcePositions",
+ FunctionTemplate::New(isolate, TestVerifySourcePositions));
+ }
// Correctness fuzzing will attempt to compare results of tests with and
// without turbo_fast_api_calls, so we don't expose the fast_c_api
// constructor when --correctness_fuzzer_suppressions is on.
if (i::FLAG_turbo_fast_api_calls &&
!i::FLAG_correctness_fuzzer_suppressions) {
- test_template->Set(isolate, "fast_c_api",
+ test_template->Set(isolate, "FastCAPI",
Shell::CreateTestFastCApiTemplate(isolate));
+ test_template->Set(isolate, "LeafInterfaceType",
+ Shell::CreateLeafInterfaceTypeTemplate(isolate));
}
d8_template->Set(isolate, "test", test_template);
@@ -3209,13 +3268,13 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
String::Utf8Value filename(isolate, args[0]);
int length;
if (*filename == nullptr) {
- Throw(isolate, "Error loading file");
+ isolate->ThrowError("Error loading file");
return;
}
uint8_t* data = reinterpret_cast<uint8_t*>(ReadChars(*filename, &length));
if (data == nullptr) {
- Throw(isolate, "Error reading file");
+ isolate->ThrowError("Error reading file");
return;
}
std::unique_ptr<v8::BackingStore> backing_store =
@@ -3882,7 +3941,7 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope handle_scope(isolate);
if (args.Length() < 1) {
- Throw(isolate, "Invalid argument");
+ isolate->ThrowError("Invalid argument");
return;
}
@@ -3923,25 +3982,6 @@ bool Shell::SetOptions(int argc, char* argv[]) {
strcmp(argv[i], "--no-stress-opt") == 0) {
options.stress_opt = false;
argv[i] = nullptr;
- } else if (strcmp(argv[i], "--stress-snapshot") == 0) {
- options.stress_snapshot = true;
- // Incremental marking is incompatible with the stress_snapshot mode;
- // specifically, serialization may clear bytecode arrays from shared
- // function infos which the MarkCompactCollector (running concurrently)
- // may still need. See also https://crbug.com/v8/10882.
- //
- // We thus force the implication
- //
- // --stress-snapshot ~~> --no-incremental-marking
- //
- // Note: This is not an issue in production because we don't clear SFI's
- // there (that only happens in mksnapshot and in --stress-snapshot mode).
- i::FLAG_incremental_marking = false;
- argv[i] = nullptr;
- } else if (strcmp(argv[i], "--nostress-snapshot") == 0 ||
- strcmp(argv[i], "--no-stress-snapshot") == 0) {
- options.stress_snapshot = false;
- argv[i] = nullptr;
} else if (strcmp(argv[i], "--noalways-opt") == 0 ||
strcmp(argv[i], "--no-always-opt") == 0) {
no_always_opt = true;
@@ -4080,6 +4120,12 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--web-snapshot-config=", 22) == 0) {
options.web_snapshot_config = argv[i] + 22;
argv[i] = nullptr;
+ } else if (strcmp(argv[i], "--compile-only") == 0) {
+ options.compile_only = true;
+ argv[i] = nullptr;
+ } else if (strncmp(argv[i], "--repeat-compile=", 17) == 0) {
+ options.repeat_compile = atoi(argv[i] + 17);
+ argv[i] = nullptr;
#ifdef V8_FUZZILLI
} else if (strcmp(argv[i], "--no-fuzzilli-enable-builtins-coverage") == 0) {
options.fuzzilli_enable_builtins_coverage = false;
@@ -4091,11 +4137,15 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--fuzzy-module-file-extensions") == 0) {
options.fuzzy_module_file_extensions = true;
argv[i] = nullptr;
-#if defined(V8_OS_WIN) && defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
+#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
} else if (strcmp(argv[i], "--enable-system-instrumentation") == 0) {
options.enable_system_instrumentation = true;
options.trace_enabled = true;
+#if defined(V8_OS_WIN)
+ // Guard this bc the flag has a lot of overhead and is not currently used
+ // by macos
i::FLAG_interpreted_frames_native_stack = true;
+#endif
argv[i] = nullptr;
#endif
}
@@ -4186,7 +4236,7 @@ int Shell::RunMain(Isolate* isolate, bool last_run) {
DisposeModuleEmbedderData(context);
}
WriteLcovData(isolate, options.lcov_file);
- if (last_run && options.stress_snapshot) {
+ if (last_run && i::FLAG_stress_snapshot) {
static constexpr bool kClearRecompilableData = true;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::Context> i_context = Utils::OpenHandle(*context);
@@ -4448,7 +4498,8 @@ class Serializer : public ValueSerializer::Delegate {
Local<Value> element;
if (transfer_array->Get(context, i).ToLocal(&element)) {
if (!element->IsArrayBuffer()) {
- Throw(isolate_, "Transfer array elements must be an ArrayBuffer");
+ isolate_->ThrowError(
+ "Transfer array elements must be an ArrayBuffer");
return Nothing<bool>();
}
@@ -4456,8 +4507,8 @@ class Serializer : public ValueSerializer::Delegate {
if (std::find(array_buffers_.begin(), array_buffers_.end(),
array_buffer) != array_buffers_.end()) {
- Throw(isolate_,
- "ArrayBuffer occurs in the transfer array more than once");
+ isolate_->ThrowError(
+ "ArrayBuffer occurs in the transfer array more than once");
return Nothing<bool>();
}
@@ -4472,7 +4523,7 @@ class Serializer : public ValueSerializer::Delegate {
} else if (transfer->IsUndefined()) {
return Just(true);
} else {
- Throw(isolate_, "Transfer list must be an Array or undefined");
+ isolate_->ThrowError("Transfer list must be an Array or undefined");
return Nothing<bool>();
}
}
@@ -4482,7 +4533,7 @@ class Serializer : public ValueSerializer::Delegate {
Local<ArrayBuffer> array_buffer =
Local<ArrayBuffer>::New(isolate_, global_array_buffer);
if (!array_buffer->IsDetachable()) {
- Throw(isolate_, "ArrayBuffer could not be transferred");
+ isolate_->ThrowError("ArrayBuffer could not be transferred");
return Nothing<bool>();
}