Skip to content

Commit

Permalink
fixup! deps: cherry-pick dbfe4a49d8 from upstream V8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Feb 1, 2018
1 parent 8102dbb commit b369026
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 67 deletions.
33 changes: 20 additions & 13 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1070,15 +1070,17 @@ class ScriptOrigin {
Local<Value> source_map_url = Local<Value>(),
Local<Boolean> resource_is_opaque = Local<Boolean>(),
Local<Boolean> is_wasm = Local<Boolean>(),
Local<Boolean> is_module = Local<Boolean>(),
Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
Local<Boolean> is_module = Local<Boolean>() /*,
// Backed out for ABI compatibility with V8 6.2
Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>() */);

V8_INLINE Local<Value> ResourceName() const;
V8_INLINE Local<Integer> ResourceLineOffset() const;
V8_INLINE Local<Integer> ResourceColumnOffset() const;
V8_INLINE Local<Integer> ScriptID() const;
V8_INLINE Local<Value> SourceMapUrl() const;
V8_INLINE Local<PrimitiveArray> HostDefinedOptions() const;
// Backed out for ABI compatibility with V8 6.2
// V8_INLINE Local<PrimitiveArray> HostDefinedOptions() const;
V8_INLINE ScriptOriginOptions Options() const { return options_; }

private:
Expand All @@ -1088,7 +1090,8 @@ class ScriptOrigin {
ScriptOriginOptions options_;
Local<Integer> script_id_;
Local<Value> source_map_url_;
Local<PrimitiveArray> host_defined_options_;
// Backed out for ABI compatibility with V8 6.2
// Local<PrimitiveArray> host_defined_options_;
};

/**
Expand Down Expand Up @@ -1335,7 +1338,7 @@ class V8_EXPORT ScriptCompiler {
Local<Integer> resource_column_offset;
ScriptOriginOptions resource_options;
Local<Value> source_map_url;
Local<PrimitiveArray> host_defined_options;
// Local<PrimitiveArray> host_defined_options;

// Cached data from previous compilation (if a kConsume*Cache flag is
// set), or hold newly generated cache data (kProduce*Cache flags) are
Expand Down Expand Up @@ -9593,8 +9596,9 @@ ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
Local<Integer> script_id,
Local<Value> source_map_url,
Local<Boolean> resource_is_opaque,
Local<Boolean> is_wasm, Local<Boolean> is_module,
Local<PrimitiveArray> host_defined_options)
Local<Boolean> is_wasm, Local<Boolean> is_module /*,
// Backed out for ABI compatibility with V8 6.2
Local<PrimitiveArray> host_defined_options */)
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
Expand All @@ -9604,14 +9608,16 @@ ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
!is_wasm.IsEmpty() && is_wasm->IsTrue(),
!is_module.IsEmpty() && is_module->IsTrue()),
script_id_(script_id),
source_map_url_(source_map_url),
host_defined_options_(host_defined_options) {}
source_map_url_(source_map_url) /*,
// Backed out for ABI compatibility with V8 6.2
host_defined_options_(host_defined_options) */ {}

Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }

Local<PrimitiveArray> ScriptOrigin::HostDefinedOptions() const {
return host_defined_options_;
}
// Backed out for ABI compatibility with V8 6.2
// Local<PrimitiveArray> ScriptOrigin::HostDefinedOptions() const {
// return host_defined_options_;
// }

Local<Integer> ScriptOrigin::ResourceLineOffset() const {
return resource_line_offset_;
Expand All @@ -9636,7 +9642,8 @@ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
resource_column_offset(origin.ResourceColumnOffset()),
resource_options(origin.Options()),
source_map_url(origin.SourceMapUrl()),
host_defined_options(origin.HostDefinedOptions()),
// Backed out for ABI compatibility with V8 6.2
// host_defined_options(origin.HostDefinedOptions()),
cached_data(data) {}

ScriptCompiler::Source::Source(Local<String> string,
Expand Down
43 changes: 25 additions & 18 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
i::Handle<i::Script> script) {
i::Handle<i::Object> scriptName(script->GetNameOrSourceURL(), isolate);
i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate);
i::Handle<i::FixedArray> host_defined_options(script->host_defined_options(),
isolate);
// Backed out for ABI compatibility with V8 6.2
// i::Handle<i::FixedArray> host_defined_options(script->host_defined_options(),
// isolate);
v8::Isolate* v8_isolate =
reinterpret_cast<v8::Isolate*>(script->GetIsolate());
ScriptOriginOptions options(script->origin_options());
Expand All @@ -292,8 +293,9 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
Utils::ToLocal(source_map_url),
v8::Boolean::New(v8_isolate, options.IsOpaque()),
v8::Boolean::New(v8_isolate, script->type() == i::Script::TYPE_WASM),
v8::Boolean::New(v8_isolate, options.IsModule()),
Utils::ToLocal(host_defined_options));
v8::Boolean::New(v8_isolate, options.IsModule()) /*,
// Backed out for ABI compatibility with V8 6.2
Utils::ToLocal(host_defined_options) */);
return origin;
}

Expand Down Expand Up @@ -2097,8 +2099,10 @@ Local<PrimitiveArray> ScriptOrModule::GetHostDefinedOptions() {
i::Handle<i::Script> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
i::Handle<i::FixedArray> val(obj->host_defined_options(), isolate);
return ToApiHandle<PrimitiveArray>(val);
// Backed out for ABI compatibility with V8 6.2
// i::Handle<i::FixedArray> val(obj->host_defined_options(), isolate);
// return ToApiHandle<PrimitiveArray>(val);
return Local<PrimitiveArray>();
}

Local<UnboundScript> Script::GetUnboundScript() {
Expand Down Expand Up @@ -2283,16 +2287,18 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileScript");
i::Handle<i::Object> name_obj;
i::Handle<i::Object> source_map_url;
i::Handle<i::FixedArray> host_defined_options =
isolate->factory()->empty_fixed_array();
// Backed out for ABI compatibility with V8 6.2
// i::Handle<i::FixedArray> host_defined_options =
// isolate->factory()->empty_fixed_array();
int line_offset = 0;
int column_offset = 0;
if (!source->resource_name.IsEmpty()) {
name_obj = Utils::OpenHandle(*(source->resource_name));
}
if (!source->host_defined_options.IsEmpty()) {
host_defined_options = Utils::OpenHandle(*(source->host_defined_options));
}
// Backed out for ABI compatibility with V8 6.2
// if (!source->host_defined_options.IsEmpty()) {
// host_defined_options = Utils::OpenHandle(*(source->host_defined_options));
// }
if (!source->resource_line_offset.IsEmpty()) {
line_offset = static_cast<int>(source->resource_line_offset->Value());
}
Expand All @@ -2306,7 +2312,7 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
result = i::Compiler::GetSharedFunctionInfoForScript(
str, name_obj, line_offset, column_offset, source->resource_options,
source_map_url, isolate->native_context(), NULL, &script_data, options,
i::NOT_NATIVES_CODE, host_defined_options);
i::NOT_NATIVES_CODE /*, host_defined_options */);
has_pending_exception = result.is_null();
if (has_pending_exception && script_data != NULL) {
// This case won't happen during normal operation; we have compiled
Expand Down Expand Up @@ -2571,10 +2577,10 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
if (!origin.ResourceName().IsEmpty()) {
script->set_name(*Utils::OpenHandle(*(origin.ResourceName())));
}
if (!origin.HostDefinedOptions().IsEmpty()) {
script->set_host_defined_options(
*Utils::OpenHandle(*(origin.HostDefinedOptions())));
}
// if (!origin.HostDefinedOptions().IsEmpty()) {
// script->set_host_defined_options(
// *Utils::OpenHandle(*(origin.HostDefinedOptions())));
// }
if (!origin.ResourceLineOffset().IsEmpty()) {
script->set_line_offset(
static_cast<int>(origin.ResourceLineOffset()->Value()));
Expand Down Expand Up @@ -9895,8 +9901,9 @@ MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate,
i::Handle<i::Object>(), isolate->native_context(), NULL, &script_data,
ScriptCompiler::kNoCompileOptions,
i::FLAG_expose_inspector_scripts ? i::NOT_NATIVES_CODE
: i::INSPECTOR_CODE,
i::Handle<i::FixedArray>());
: i::INSPECTOR_CODE /*,
// Backed out for ABI compatibility with V8 6.2
i::Handle<i::FixedArray>() */);
has_pending_exception = result.is_null();
RETURN_ON_FAILED_EXECUTION(UnboundScript);
}
Expand Down
9 changes: 6 additions & 3 deletions deps/v8/src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3539,8 +3539,9 @@ bool Bootstrapper::CompileNative(Isolate* isolate, Vector<const char> name,
Handle<SharedFunctionInfo> function_info =
Compiler::GetSharedFunctionInfoForScript(
source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
context, NULL, NULL, ScriptCompiler::kNoCompileOptions, natives_flag,
Handle<FixedArray>());
context, NULL, NULL, ScriptCompiler::kNoCompileOptions, natives_flag);
// Backed out for ABI compatibility with V8 6.2
// Handle<FixedArray>());
if (function_info.is_null()) return false;

DCHECK(context->IsNativeContext());
Expand Down Expand Up @@ -3603,7 +3604,9 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
function_info = Compiler::GetSharedFunctionInfoForScript(
source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
context, extension, NULL, ScriptCompiler::kNoCompileOptions,
EXTENSION_CODE, Handle<FixedArray>());
// Backed out for ABI compatibility with V8 6.2
// EXTENSION_CODE, Handle<FixedArray>());
EXTENSION_CODE);
if (function_info.is_null()) return false;
cache->Add(name, function_info);
}
Expand Down
13 changes: 8 additions & 5 deletions deps/v8/src/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,10 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
int column_offset, ScriptOriginOptions resource_options,
Handle<Object> source_map_url, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
Handle<FixedArray> host_defined_options) {
// Backed out for ABI compatibility with V8 6.2
// ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
// Handle<FixedArray> host_defined_options) {
ScriptCompiler::CompileOptions compile_options, NativesFlag natives) {
Isolate* isolate = source->GetIsolate();
if (compile_options == ScriptCompiler::kNoCompileOptions) {
cached_data = NULL;
Expand Down Expand Up @@ -1289,9 +1291,10 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
if (!source_map_url.is_null()) {
script->set_source_mapping_url(*source_map_url);
}
if (!host_defined_options.is_null()) {
script->set_host_defined_options(*host_defined_options);
}
// Backed out for ABI compatibility with V8 6.2
// if (!host_defined_options.is_null()) {
// script->set_host_defined_options(*host_defined_options);
// }

// Compile the function and add it to the cache.
ParseInfo parse_info(script);
Expand Down
4 changes: 3 additions & 1 deletion deps/v8/src/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
Handle<Object> source_map_url, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options,
NativesFlag is_natives_code, Handle<FixedArray> host_defined_options);
NativesFlag is_natives_code);
// Backed out for ABI compatibility with V8 6.2
// NativesFlag is_natives_code, Handle<FixedArray> host_defined_options);

// Create a shared function info object for a Script that has already been
// parsed while the script was being loaded from a streamed source.
Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,8 @@ Handle<Script> Factory::NewScript(Handle<String> source) {
script->set_eval_from_position(0);
script->set_shared_function_infos(*empty_fixed_array(), SKIP_WRITE_BARRIER);
script->set_flags(0);
script->set_host_defined_options(*empty_fixed_array());
// Backed out for ABI compatibility with V8 6.2
// script->set_host_defined_options(*empty_fixed_array());
heap->set_script_list(*WeakFixedArray::Add(script_list(), script));
return script;
}
Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/objects/script-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ACCESSORS(Script, shared_function_infos, FixedArray, kSharedFunctionInfosOffset)
SMI_ACCESSORS(Script, flags, kFlagsOffset)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
ACCESSORS(Script, host_defined_options, FixedArray, kHostDefinedOptionsOffset)
// Backed out for ABI compatibility with V8 6.2
// ACCESSORS(Script, host_defined_options, FixedArray, kHostDefinedOptionsOffset)
ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
this->type() == TYPE_WASM)

Expand Down
13 changes: 8 additions & 5 deletions deps/v8/src/objects/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ class Script : public Struct {
// This must only be called if the type of this script is TYPE_WASM.
DECL_ACCESSORS(wasm_compiled_module, Object)

// [host_defined_options]: Options defined by the embedder.
DECL_ACCESSORS(host_defined_options, FixedArray)
// Backed out for ABI compatibility with V8 6.2
// // [host_defined_options]: Options defined by the embedder.
// DECL_ACCESSORS(host_defined_options, FixedArray)

// [compilation_type]: how the the script was compiled. Encoded in the
// 'flags' field.
Expand Down Expand Up @@ -198,9 +199,11 @@ class Script : public Struct {
static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
static const int kHostDefinedOptionsOffset =
kSourceMappingUrlOffset + kPointerSize;
static const int kSize = kHostDefinedOptionsOffset + kPointerSize;
// Backed out for ABI compatibility with V8 6.2
// static const int kHostDefinedOptionsOffset =
// kSourceMappingUrlOffset + kPointerSize;
// static const int kSize = kHostDefinedOptionsOffset + kPointerSize;
static const int kSize = kSourceMappingUrlOffset + kPointerSize;

private:
// Bit positions in the flags field.
Expand Down
6 changes: 4 additions & 2 deletions deps/v8/test/cctest/compiler/test-linkage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ static Handle<JSFunction> Compile(const char* source) {
Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript(
source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
Handle<FixedArray>());
// Backed out for ABI compatibility with V8 6.2
// v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
// Handle<FixedArray>());
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context());
}
Expand Down
34 changes: 21 additions & 13 deletions deps/v8/test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19108,18 +19108,21 @@ TEST(Regress528) {

THREADED_TEST(ScriptOrigin) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
Local<v8::PrimitiveArray> array(v8::PrimitiveArray::New(isolate, 1));
Local<v8::Symbol> symbol(v8::Symbol::New(isolate));
array->Set(0, symbol);
// Backed out for ABI compatibility with V8 6.2
// v8::Isolate* isolate = env->GetIsolate();
// v8::HandleScope scope(isolate);
// Local<v8::PrimitiveArray> array(v8::PrimitiveArray::New(isolate, 1));
// Local<v8::Symbol> symbol(v8::Symbol::New(isolate));
// array->Set(0, symbol);

v8::ScriptOrigin origin = v8::ScriptOrigin(
v8_str("test"), v8::Integer::New(env->GetIsolate(), 1),
v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()),
v8::Local<v8::Integer>(), v8_str("http://sourceMapUrl"),
v8::True(env->GetIsolate()), v8::False(env->GetIsolate()),
v8::False(env->GetIsolate()), array);
// Backed out for ABI compatibility with V8 6.2
// v8::False(env->GetIsolate()), array);
v8::False(env->GetIsolate()));
v8::Local<v8::String> script = v8_str("function f() {}\n\nfunction g() {}");
v8::Script::Compile(env.local(), script, &origin)
.ToLocalChecked()
Expand All @@ -19140,7 +19143,8 @@ THREADED_TEST(ScriptOrigin) {
CHECK(script_origin_f.Options().IsSharedCrossOrigin());
CHECK(script_origin_f.Options().IsOpaque());
printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined());
CHECK(script_origin_f.HostDefinedOptions()->Get(0)->IsSymbol());
// Backed out for ABI compatibility with V8 6.2
// CHECK(script_origin_f.HostDefinedOptions()->Get(0)->IsSymbol());

CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(env->GetIsolate(),
Expand All @@ -19158,7 +19162,8 @@ THREADED_TEST(ScriptOrigin) {
CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(env->GetIsolate(),
script_origin_g.SourceMapUrl())));
CHECK(script_origin_g.HostDefinedOptions()->Get(0)->IsSymbol());
// Backed out for ABI compatibility with V8 6.2
// CHECK(script_origin_g.HostDefinedOptions()->Get(0)->IsSymbol());
}


Expand Down Expand Up @@ -27082,7 +27087,8 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamicallyCallbackResolve(
String::Utf8Value referrer_utf8(
context->GetIsolate(), Local<String>::Cast(referrer->GetResourceName()));
CHECK_EQ(0, strcmp("www.google.com", *referrer_utf8));
CHECK(referrer->GetHostDefinedOptions()->Get(0)->IsSymbol());
// Backed out for ABI compatibility with V8 6.2
// CHECK(referrer->GetHostDefinedOptions()->Get(0)->IsSymbol());

CHECK(!specifier.IsEmpty());
String::Utf8Value specifier_utf8(context->GetIsolate(), specifier);
Expand All @@ -27109,12 +27115,14 @@ TEST(DynamicImport) {
i::Handle<i::String> result(v8::Utils::OpenHandle(*v8_str("hello world")));
i::Handle<i::String> source(v8::Utils::OpenHandle(*v8_str("foo")));
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::FixedArray> options = i_isolate->factory()->NewFixedArray(1);
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewSymbol();
options->set(0, *symbol);
// Backed out for ABI compatibility with V8 6.2
// i::Handle<i::FixedArray> options = i_isolate->factory()->NewFixedArray(1);
// i::Handle<i::Symbol> symbol = i_isolate->factory()->NewSymbol();
// options->set(0, *symbol);
i::Handle<i::Script> referrer = i_isolate->factory()->NewScript(source);
referrer->set_name(*url);
referrer->set_host_defined_options(*options);
// Backed out for ABI compatibility with V8 6.2
// referrer->set_host_defined_options(*options);
i::MaybeHandle<i::JSPromise> maybe_promise =
i_isolate->RunHostImportModuleDynamicallyCallback(referrer, specifier);
i::Handle<i::JSPromise> promise = maybe_promise.ToHandleChecked();
Expand Down
6 changes: 4 additions & 2 deletions deps/v8/test/cctest/test-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ static Handle<JSFunction> Compile(const char* source) {
Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript(
source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
Handle<FixedArray>());
// Backed out for ABI compatibility with V8 6.2
// v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
// Handle<FixedArray>());
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context());
}
Expand Down
Loading

0 comments on commit b369026

Please sign in to comment.