/**
+ * The optional attributes of ScriptOrigin.
+ */
+class ScriptOriginOptions {
+ public:
+ V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script = false,
+ bool is_shared_cross_origin = false,
+ bool is_opaque = false)
+ : flags_((is_embedder_debug_script ? kIsEmbedderDebugScript : 0) |
+ (is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
+ (is_opaque ? kIsOpaque : 0)) {}
+ V8_INLINE ScriptOriginOptions(int flags)
+ : flags_(flags &
+ (kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {}
+ bool IsEmbedderDebugScript() const {
+ return (flags_ & kIsEmbedderDebugScript) != 0;
+ }
+ bool IsSharedCrossOrigin() const {
+ return (flags_ & kIsSharedCrossOrigin) != 0;
+ }
+ bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
+ int Flags() const { return flags_; }
+
+ private:
+ enum {
+ kIsEmbedderDebugScript = 1,
+ kIsSharedCrossOrigin = 1 << 1,
+ kIsOpaque = 1 << 2
+ };
+ const int flags_;
+};
+
+/**
* The origin, within a file, of a script.
*/
class ScriptOrigin {
Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
Handle<Integer> script_id = Handle<Integer>(),
Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(),
- Handle<Value> source_map_url = Handle<Value>())
- : resource_name_(resource_name),
- resource_line_offset_(resource_line_offset),
- resource_column_offset_(resource_column_offset),
- resource_is_embedder_debug_script_(resource_is_embedder_debug_script),
- resource_is_shared_cross_origin_(resource_is_shared_cross_origin),
- script_id_(script_id),
- source_map_url_(source_map_url) {}
+ Handle<Value> source_map_url = Handle<Value>(),
+ Handle<Boolean> resource_is_opaque = Handle<Boolean>());
V8_INLINE Handle<Value> ResourceName() const;
V8_INLINE Handle<Integer> ResourceLineOffset() const;
V8_INLINE Handle<Integer> ResourceColumnOffset() const;
/**
* Returns true for embedder's debugger scripts
*/
- V8_INLINE Handle<Boolean> ResourceIsEmbedderDebugScript() const;
- V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
V8_INLINE Handle<Integer> ScriptID() const;
V8_INLINE Handle<Value> SourceMapUrl() const;
+ V8_INLINE ScriptOriginOptions Options() const { return options_; }
private:
Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_;
- Handle<Boolean> resource_is_embedder_debug_script_;
- Handle<Boolean> resource_is_shared_cross_origin_;
+ ScriptOriginOptions options_;
Handle<Integer> script_id_;
Handle<Value> source_map_url_;
};
Handle<Value> resource_name;
Handle<Integer> resource_line_offset;
Handle<Integer> resource_column_offset;
- Handle<Boolean> resource_is_embedder_debug_script;
- Handle<Boolean> resource_is_shared_cross_origin;
+ ScriptOriginOptions resource_options;
Handle<Value> source_map_url;
// Cached data from previous compilation (if a kConsume*Cache flag is
* this Message was generated to V8.
*/
bool IsSharedCrossOrigin() const;
+ bool IsOpaque() const;
// TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
return length_;
}
+ScriptOrigin::ScriptOrigin(Handle<Value> resource_name,
+ Handle<Integer> resource_line_offset,
+ Handle<Integer> resource_column_offset,
+ Handle<Boolean> resource_is_shared_cross_origin,
+ Handle<Integer> script_id,
+ Handle<Boolean> resource_is_embedder_debug_script,
+ Handle<Value> source_map_url,
+ Handle<Boolean> resource_is_opaque)
+ : resource_name_(resource_name),
+ resource_line_offset_(resource_line_offset),
+ resource_column_offset_(resource_column_offset),
+ options_(!resource_is_embedder_debug_script.IsEmpty() &&
+ resource_is_embedder_debug_script->IsTrue(),
+ !resource_is_shared_cross_origin.IsEmpty() &&
+ resource_is_shared_cross_origin->IsTrue(),
+ !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue()),
+ script_id_(script_id),
+ source_map_url_(source_map_url) {}
Handle<Value> ScriptOrigin::ResourceName() const {
return resource_name_;
}
-Handle<Boolean> ScriptOrigin::ResourceIsEmbedderDebugScript() const {
- return resource_is_embedder_debug_script_;
-}
-
-
-Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
- return resource_is_shared_cross_origin_;
-}
-
-
Handle<Integer> ScriptOrigin::ScriptID() const {
return script_id_;
}
resource_name(origin.ResourceName()),
resource_line_offset(origin.ResourceLineOffset()),
resource_column_offset(origin.ResourceColumnOffset()),
- resource_is_embedder_debug_script(origin.ResourceIsEmbedderDebugScript()),
- resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()),
+ resource_options(origin.Options()),
source_map_url(origin.SourceMapUrl()),
cached_data(data) {}
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
- bool is_embedder_debug_script =
- Script::cast(JSValue::cast(object)->value())->is_embedder_debug_script();
+ bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value())
+ ->origin_options()
+ .IsEmbedderDebugScript();
Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script);
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate);
v8::Isolate* v8_isolate =
reinterpret_cast<v8::Isolate*>(script->GetIsolate());
+ ScriptOriginOptions options(script->origin_options());
v8::ScriptOrigin origin(
Utils::ToLocal(scriptName),
v8::Integer::New(v8_isolate, script->line_offset()->value()),
v8::Integer::New(v8_isolate, script->column_offset()->value()),
- v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()),
+ v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()),
v8::Integer::New(v8_isolate, script->id()->value()),
- v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()),
- Utils::ToLocal(source_map_url));
+ v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()),
+ Utils::ToLocal(source_map_url),
+ v8::Boolean::New(v8_isolate, options.IsOpaque()));
return origin;
}
i::Handle<i::Object> source_map_url;
int line_offset = 0;
int column_offset = 0;
- bool is_embedder_debug_script = false;
- bool is_shared_cross_origin = false;
if (!source->resource_name.IsEmpty()) {
name_obj = Utils::OpenHandle(*(source->resource_name));
}
column_offset =
static_cast<int>(source->resource_column_offset->Value());
}
- if (!source->resource_is_shared_cross_origin.IsEmpty()) {
- is_shared_cross_origin =
- source->resource_is_shared_cross_origin->IsTrue();
- }
- if (!source->resource_is_embedder_debug_script.IsEmpty()) {
- is_embedder_debug_script =
- source->resource_is_embedder_debug_script->IsTrue();
- }
if (!source->source_map_url.IsEmpty()) {
source_map_url = Utils::OpenHandle(*(source->source_map_url));
}
result = i::Compiler::CompileScript(
- str, name_obj, line_offset, column_offset, is_embedder_debug_script,
- is_shared_cross_origin, source_map_url, isolate->native_context(), NULL,
- &script_data, options, i::NOT_NATIVES_CODE, is_module);
+ str, name_obj, line_offset, column_offset, source->resource_options,
+ source_map_url, isolate->native_context(), NULL, &script_data, options,
+ i::NOT_NATIVES_CODE, is_module);
has_pending_exception = result.is_null();
if (has_pending_exception && script_data != NULL) {
// This case won't happen during normal operation; we have compiled
script->set_column_offset(i::Smi::FromInt(
static_cast<int>(origin.ResourceColumnOffset()->Value())));
}
- if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) {
- script->set_is_shared_cross_origin(
- origin.ResourceIsSharedCrossOrigin()->IsTrue());
- }
- if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) {
- script->set_is_embedder_debug_script(
- origin.ResourceIsEmbedderDebugScript()->IsTrue());
- }
+ script->set_origin_options(origin.Options());
if (!origin.SourceMapUrl().IsEmpty()) {
script->set_source_mapping_url(
*Utils::OpenHandle(*(origin.SourceMapUrl())));
auto self = Utils::OpenHandle(this);
auto script = i::Handle<i::JSValue>::cast(
i::Handle<i::Object>(self->script(), isolate));
- return i::Script::cast(script->value())->is_shared_cross_origin();
+ return i::Script::cast(script->value())
+ ->origin_options()
+ .IsSharedCrossOrigin();
+}
+
+bool Message::IsOpaque() const {
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ ENTER_V8(isolate);
+ auto self = Utils::OpenHandle(this);
+ auto script = i::Handle<i::JSValue>::cast(
+ i::Handle<i::Object>(self->script(), isolate));
+ return i::Script::cast(script->value())->origin_options().IsOpaque();
}
Handle<String> script_name =
isolate->factory()->NewStringFromUtf8(name).ToHandleChecked();
Handle<SharedFunctionInfo> function_info = Compiler::CompileScript(
- source, script_name, 0, 0, false, false, Handle<Object>(), context, NULL,
- NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false);
+ source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
+ context, NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE,
+ false);
if (function_info.is_null()) return false;
DCHECK(context->IsNativeContext());
Handle<String> script_name =
factory->NewStringFromUtf8(name).ToHandleChecked();
function_info = Compiler::CompileScript(
- source, script_name, 0, 0, false, false, Handle<Object>(), context,
- extension, NULL, ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
- false);
+ source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
+ context, extension, NULL, ScriptCompiler::kNoCompileOptions,
+ NOT_NATIVES_CODE, false);
if (function_info.is_null()) return false;
cache->Add(name, function_info);
}
bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
Handle<Object> name, int line_offset,
int column_offset,
- bool is_embedder_debug_script,
- bool is_shared_cross_origin) {
+ ScriptOriginOptions resource_options) {
Handle<Script> script =
Handle<Script>(Script::cast(function_info->script()), isolate());
// If the script name isn't set, the boilerplate script should have
if (column_offset != script->column_offset()->value()) return false;
// Check that both names are strings. If not, no match.
if (!name->IsString() || !script->name()->IsString()) return false;
- // Were both scripts tagged by the embedder as being internal script?
- if (is_embedder_debug_script != script->is_embedder_debug_script()) {
+ // Are the origin_options same?
+ if (resource_options.Flags() != script->origin_options().Flags())
return false;
- }
- // Were both scripts tagged by the embedder as being shared cross-origin?
- if (is_shared_cross_origin != script->is_shared_cross_origin()) return false;
// Compare the two name strings for equality.
return String::Equals(Handle<String>::cast(name),
Handle<String>(String::cast(script->name())));
// won't.
Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
Handle<String> source, Handle<Object> name, int line_offset,
- int column_offset, bool is_embedder_debug_script,
- bool is_shared_cross_origin, Handle<Context> context,
- LanguageMode language_mode) {
+ int column_offset, ScriptOriginOptions resource_options,
+ Handle<Context> context, LanguageMode language_mode) {
Object* result = NULL;
int generation;
// Break when we've found a suitable shared function info that
// matches the origin.
if (HasOrigin(function_info, name, line_offset, column_offset,
- is_embedder_debug_script, is_shared_cross_origin)) {
+ resource_options)) {
result = *function_info;
break;
}
if (result != NULL) {
Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result),
isolate());
- DCHECK(HasOrigin(shared, name, line_offset, column_offset,
- is_embedder_debug_script, is_shared_cross_origin));
+ DCHECK(
+ HasOrigin(shared, name, line_offset, column_offset, resource_options));
// If the script was found in a later generation, we promote it to
// the first generation to let it survive longer in the cache.
if (generation != 0) Put(source, context, language_mode, shared);
MaybeHandle<SharedFunctionInfo> CompilationCache::LookupScript(
Handle<String> source, Handle<Object> name, int line_offset,
- int column_offset, bool is_embedder_debug_script,
- bool is_shared_cross_origin, Handle<Context> context,
- LanguageMode language_mode) {
+ int column_offset, ScriptOriginOptions resource_options,
+ Handle<Context> context, LanguageMode language_mode) {
if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
return script_.Lookup(source, name, line_offset, column_offset,
- is_embedder_debug_script, is_shared_cross_origin,
- context, language_mode);
+ resource_options, context, language_mode);
}
Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name,
int line_offset, int column_offset,
- bool is_embedder_debug_script,
- bool is_shared_cross_origin,
+ ScriptOriginOptions resource_options,
Handle<Context> context,
LanguageMode language_mode);
void Put(Handle<String> source,
private:
bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name,
int line_offset, int column_offset,
- bool is_embedder_debug_script, bool is_shared_cross_origin);
+ ScriptOriginOptions resource_options);
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
};
// script for the given source string with the right origin.
MaybeHandle<SharedFunctionInfo> LookupScript(
Handle<String> source, Handle<Object> name, int line_offset,
- int column_offset, bool is_embedder_debug_script,
- bool is_shared_cross_origin, Handle<Context> context,
- LanguageMode language_mode);
+ int column_offset, ScriptOriginOptions resource_options,
+ Handle<Context> context, LanguageMode language_mode);
// Finds the shared function info for a source string for eval in a
// given context. Returns an empty handle if the cache doesn't
Handle<SharedFunctionInfo> Compiler::CompileScript(
Handle<String> source, Handle<Object> script_name, int line_offset,
- int column_offset, bool is_embedder_debug_script,
- bool is_shared_cross_origin, Handle<Object> source_map_url,
- Handle<Context> context, v8::Extension* extension, ScriptData** cached_data,
+ 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,
bool is_module) {
Isolate* isolate = source->GetIsolate();
if (extension == NULL) {
// First check per-isolate compilation cache.
maybe_result = compilation_cache->LookupScript(
- source, script_name, line_offset, column_offset,
- is_embedder_debug_script, is_shared_cross_origin, context,
- language_mode);
+ source, script_name, line_offset, column_offset, resource_options,
+ context, language_mode);
if (maybe_result.is_null() && FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kConsumeCodeCache &&
!isolate->debug()->is_loaded()) {
script->set_line_offset(Smi::FromInt(line_offset));
script->set_column_offset(Smi::FromInt(column_offset));
}
- script->set_is_shared_cross_origin(is_shared_cross_origin);
- script->set_is_embedder_debug_script(is_embedder_debug_script);
+ script->set_origin_options(resource_options);
if (!source_map_url.is_null()) {
script->set_source_mapping_url(*source_map_url);
}
// Compile a String source within a context.
static Handle<SharedFunctionInfo> CompileScript(
Handle<String> source, Handle<Object> script_name, int line_offset,
- int column_offset, bool is_debugger_script, bool is_shared_cross_origin,
+ int column_offset, ScriptOriginOptions resource_options,
Handle<Object> source_map_url, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options,
// Compile the script.
Handle<SharedFunctionInfo> function_info;
function_info = Compiler::CompileScript(
- source_code, script_name, 0, 0, false, false, Handle<Object>(), context,
- NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false);
+ source_code, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
+ context, NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE,
+ false);
// Silently ignore stack overflows during compilation.
if (function_info.is_null()) {
ACCESSORS_TO_SMI(Script, eval_from_instructions_offset,
kEvalFrominstructionsOffsetOffset)
ACCESSORS_TO_SMI(Script, flags, kFlagsOffset)
-BOOL_ACCESSORS(Script, flags, is_embedder_debug_script,
- kIsEmbedderDebugScriptBit)
-BOOL_ACCESSORS(Script, flags, is_shared_cross_origin, kIsSharedCrossOriginBit)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
set_flags(BooleanBit::set(flags(), kCompilationStateBit,
state == COMPILATION_STATE_COMPILED));
}
+ScriptOriginOptions Script::origin_options() {
+ return ScriptOriginOptions((flags()->value() & kOriginOptionsMask) >>
+ kOriginOptionsShift);
+}
+void Script::set_origin_options(ScriptOriginOptions origin_options) {
+ DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
+ set_flags(Smi::FromInt((flags()->value() & ~kOriginOptionsMask) |
+ (origin_options.Flags() << kOriginOptionsShift)));
+}
ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)
inline CompilationState compilation_state();
inline void set_compilation_state(CompilationState state);
- // [is_embedder_debug_script]: An opaque boolean set by the embedder via
- // ScriptOrigin, and used by the embedder to make decisions about the
- // script's origin. V8 just passes this through. Encoded in
- // the 'flags' field.
- DECL_BOOLEAN_ACCESSORS(is_embedder_debug_script)
-
- // [is_shared_cross_origin]: An opaque boolean set by the embedder via
- // ScriptOrigin, and used by the embedder to make decisions about the
- // script's level of privilege. V8 just passes this through. Encoded in
- // the 'flags' field.
- DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin)
+ // [origin_options]: optional attributes set by the embedder via ScriptOrigin,
+ // and used by the embedder to make decisions about the script. V8 just passes
+ // this through. Encoded in the 'flags' field.
+ inline v8::ScriptOriginOptions origin_options();
+ inline void set_origin_options(ScriptOriginOptions origin_options);
DECLARE_CAST(Script)
// Bit positions in the flags field.
static const int kCompilationTypeBit = 0;
static const int kCompilationStateBit = 1;
- static const int kIsEmbedderDebugScriptBit = 2;
- static const int kIsSharedCrossOriginBit = 3;
+ static const int kOriginOptionsShift = 2;
+ static const int kOriginOptionsSize = 3;
+ static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
+ << kOriginOptionsShift;
DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
};
->NewStringFromUtf8(CStrVector(source))
.ToHandleChecked();
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
- source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(),
- Handle<Context>(isolate->native_context()), NULL, NULL,
+ source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
+ Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());
static void check_message_3(v8::Handle<v8::Message> message,
v8::Handle<Value> data) {
CHECK(message->IsSharedCrossOrigin());
- CHECK(message->GetScriptOrigin().ResourceIsSharedCrossOrigin()->Value());
- CHECK(message->GetScriptOrigin().ResourceIsEmbedderDebugScript()->Value());
+ CHECK(message->GetScriptOrigin().Options().IsSharedCrossOrigin());
+ CHECK(message->GetScriptOrigin().Options().IsEmbedderDebugScript());
+ CHECK(message->GetScriptOrigin().Options().IsOpaque());
CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue());
message_received = true;
v8::ScriptOrigin origin = v8::ScriptOrigin(
v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(),
- v8::True(isolate), v8_str("7.40"));
+ v8::True(isolate), v8_str("7.40"), v8::True(isolate));
v8::Handle<v8::Script> script =
Script::Compile(v8_str("throw 'error'"), &origin);
script->Run();
CHECK(!message_received);
v8::V8::AddMessageListener(check_message_5a);
LocalContext context;
- v8::ScriptOrigin origin =
+ v8::ScriptOrigin origin1 =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::True(isolate));
v8::Handle<v8::Script> script =
- Script::Compile(v8_str("throw 'error'"), &origin);
+ Script::Compile(v8_str("throw 'error'"), &origin1);
script->Run();
CHECK(message_received);
// clear out the message listener
message_received = false;
v8::V8::AddMessageListener(check_message_5b);
- origin = v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
- v8::Integer::New(isolate, 2), v8::False(isolate));
- script = Script::Compile(v8_str("throw 'error'"), &origin);
+ v8::ScriptOrigin origin2 =
+ v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
+ v8::Integer::New(isolate, 2), v8::False(isolate));
+ script = Script::Compile(v8_str("throw 'error'"), &origin2);
script->Run();
CHECK(message_received);
// clear out the message listener
v8::Integer::New(env->GetIsolate(), 1),
v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()),
v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()),
- v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"));
+ v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"),
+ v8::True(env->GetIsolate()));
v8::Handle<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(), "function f() {}\n\nfunction g() {}");
v8::Script::Compile(script, &origin)->Run();
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_f.ResourceName())));
CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value());
- CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value());
- CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value());
+ CHECK(script_origin_f.Options().IsSharedCrossOrigin());
+ CHECK(script_origin_f.Options().IsEmbedderDebugScript());
+ CHECK(script_origin_f.Options().IsOpaque());
printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined());
CHECK_EQ(0, strcmp("http://sourceMapUrl",
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_g.ResourceName())));
CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value());
- CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value());
- CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value());
+ CHECK(script_origin_g.Options().IsSharedCrossOrigin());
+ CHECK(script_origin_g.Options().IsEmbedderDebugScript());
+ CHECK(script_origin_g.Options().IsOpaque());
CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(script_origin_g.SourceMapUrl())));
}
Handle<String> source_code = isolate->factory()->NewStringFromUtf8(
CStrVector(source)).ToHandleChecked();
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
- source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(),
- Handle<Context>(isolate->native_context()), NULL, NULL,
+ source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
+ Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());
// On first compilation, only a hash is inserted in the code cache. We can't
// find that value.
MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript(
- source, Handle<Object>(), 0, 0, false, true, native_context,
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
CHECK(info.is_null());
// On second compilation, the hash is replaced by a real cache entry mapping
// the source to the shared function info containing the code.
- info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
- true, native_context, language_mode);
+ info = compilation_cache->LookupScript(
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
+ language_mode);
CHECK(!info.is_null());
heap->CollectAllGarbage();
// On second compilation, the hash is replaced by a real cache entry mapping
// the source to the shared function info containing the code.
- info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
- true, native_context, language_mode);
+ info = compilation_cache->LookupScript(
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
+ language_mode);
CHECK(!info.is_null());
while (!info.ToHandleChecked()->code()->IsOld()) {
heap->CollectAllGarbage();
// Ensure code aging cleared the entry from the cache.
- info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
- true, native_context, language_mode);
+ info = compilation_cache->LookupScript(
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
+ language_mode);
CHECK(info.is_null());
{
// On first compilation, only a hash is inserted in the code cache. We can't
// find that value.
- info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
- true, native_context, language_mode);
+ info = compilation_cache->LookupScript(
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
+ language_mode);
CHECK(info.is_null());
for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) {
// If we aged the cache before caching the script, ensure that we didn't cache
// on next compilation.
- info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
- true, native_context, language_mode);
+ info = compilation_cache->LookupScript(
+ source, Handle<Object>(), 0, 0,
+ v8::ScriptOriginOptions(false, true, false), native_context,
+ language_mode);
CHECK(info.is_null());
}
Isolate* isolate, Handle<String> source, Handle<String> name,
ScriptData** cached_data, v8::ScriptCompiler::CompileOptions options) {
return Compiler::CompileScript(
- source, name, 0, 0, false, false, Handle<Object>(),
+ source, name, 0, 0, v8::ScriptOriginOptions(), Handle<Object>(),
Handle<Context>(isolate->native_context()), NULL, cached_data, options,
NOT_NATIVES_CODE, false);
}
isolate, src, src, &cache, v8::ScriptCompiler::kConsumeCodeCache);
CHECK(isolate->compilation_cache()
- ->LookupScript(src, src, 0, 0, false, false,
+ ->LookupScript(src, src, 0, 0, v8::ScriptOriginOptions(),
isolate->native_context(), SLOPPY)
.ToHandleChecked()
.is_identical_to(copy));