[V8] Added Script::is_debugger_script flag for embedders
authorkozyatinskiy <kozyatinskiy@chromium.org>
Thu, 29 Jan 2015 14:01:13 +0000 (06:01 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 29 Jan 2015 14:01:33 +0000 (14:01 +0000)
In DevTools we need one more flag for script origin - is debugger script. We already have "is shared origin" flag. The new flag added by analogy with the old but new has accessor in script object.

R=yurys@chromium.org

Review URL: https://codereview.chromium.org/879553002

Cr-Commit-Position: refs/heads/master@{#26324}

17 files changed:
include/v8.h
src/accessors.cc
src/accessors.h
src/api.cc
src/bootstrapper.cc
src/compilation-cache.cc
src/compilation-cache.h
src/compiler.cc
src/compiler.h
src/debug.cc
src/objects-inl.h
src/objects.h
test/cctest/compiler/test-linkage.cc
test/cctest/test-api.cc
test/cctest/test-compiler.cc
test/cctest/test-heap.cc
test/cctest/test-serialize.cc

index 1df17bb..bd4cb4e 100644 (file)
@@ -976,21 +976,29 @@ class ScriptOrigin {
       Handle<Integer> resource_line_offset = Handle<Integer>(),
       Handle<Integer> resource_column_offset = Handle<Integer>(),
       Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
-      Handle<Integer> script_id = Handle<Integer>())
+      Handle<Integer> script_id = Handle<Integer>(),
+      Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>())
       : 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) { }
+        script_id_(script_id) {}
   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;
+
  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_;
   Handle<Integer> script_id_;
 };
@@ -1136,6 +1144,7 @@ class V8_EXPORT ScriptCompiler {
     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;
 
     // Cached data from previous compilation (if a kConsume*Cache flag is
@@ -6726,6 +6735,11 @@ Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
 }
 
 
+Handle<Boolean> ScriptOrigin::ResourceIsEmbedderDebugScript() const {
+  return resource_is_embedder_debug_script_;
+}
+
+
 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
   return resource_is_shared_cross_origin_;
 }
@@ -6742,6 +6756,7 @@ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
       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()),
       cached_data(data) {}
 
index 662a9e1..1e8abd9 100644 (file)
@@ -787,6 +787,40 @@ Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo(
 
 
 //
+// Accessors::ScriptIsEmbedderDebugScript
+//
+
+
+void Accessors::ScriptIsEmbedderDebugScriptGetter(
+    v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
+  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
+  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();
+  Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script);
+  info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
+}
+
+
+void Accessors::ScriptIsEmbedderDebugScriptSetter(
+    v8::Local<v8::Name> name, v8::Local<v8::Value> value,
+    const v8::PropertyCallbackInfo<void>& info) {
+  UNREACHABLE();
+}
+
+
+Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo(
+    Isolate* isolate, PropertyAttributes attributes) {
+  Handle<String> name(isolate->factory()->InternalizeOneByteString(
+      STATIC_CHAR_VECTOR("is_debugger_script")));
+  return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter,
+                      &ScriptIsEmbedderDebugScriptSetter, attributes);
+}
+
+
+//
 // Accessors::ScriptGetContextData
 //
 
index 0210d53..bf0c4e4 100644 (file)
@@ -36,6 +36,7 @@ namespace internal {
   V(ScriptType)                   \
   V(ScriptSourceUrl)              \
   V(ScriptSourceMappingUrl)       \
+  V(ScriptIsEmbedderDebugScript)  \
   V(StringLength)
 
 // Accessors contains all predefined proxy accessors.
index 9b6be9a..fd84341 100644 (file)
@@ -1602,6 +1602,7 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
     i::Handle<i::Object> name_obj;
     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));
@@ -1614,15 +1615,18 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
           static_cast<int>(source->resource_column_offset->Value());
     }
     if (!source->resource_is_shared_cross_origin.IsEmpty()) {
-      v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
       is_shared_cross_origin =
-          source->resource_is_shared_cross_origin == v8::True(v8_isolate);
+          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();
     }
     EXCEPTION_PREAMBLE(isolate);
     i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript(
-        str, name_obj, line_offset, column_offset, is_shared_cross_origin,
-        isolate->native_context(), NULL, &script_data, options,
-        i::NOT_NATIVES_CODE);
+        str, name_obj, line_offset, column_offset, is_embedder_debug_script,
+        is_shared_cross_origin, isolate->native_context(), NULL, &script_data,
+        options, i::NOT_NATIVES_CODE);
     has_pending_exception = result.is_null();
     if (has_pending_exception && script_data != NULL) {
       // This case won't happen during normal operation; we have compiled
@@ -1700,8 +1704,12 @@ Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate,
           static_cast<int>(origin.ResourceColumnOffset()->Value())));
     }
     if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) {
-      script->set_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin() ==
-                                         v8::True(v8_isolate));
+      script->set_is_shared_cross_origin(
+          origin.ResourceIsSharedCrossOrigin()->IsTrue());
+    }
+    if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) {
+      script->set_is_embedder_debug_script(
+          origin.ResourceIsEmbedderDebugScript()->IsTrue());
     }
     source->info->set_script(script);
     source->info->SetContext(isolate->native_context());
@@ -1966,8 +1974,9 @@ ScriptOrigin Message::GetScriptOrigin() const {
       Utils::ToLocal(scriptName),
       v8::Integer::New(v8_isolate, script->line_offset()->value()),
       v8::Integer::New(v8_isolate, script->column_offset()->value()),
-      Handle<Boolean>(),
-      v8::Integer::New(v8_isolate, script->id()->value()));
+      v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()),
+      v8::Integer::New(v8_isolate, script->id()->value()),
+      v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()));
   return origin;
 }
 
@@ -4137,7 +4146,10 @@ ScriptOrigin Function::GetScriptOrigin() const {
     v8::ScriptOrigin origin(
         Utils::ToLocal(scriptName),
         v8::Integer::New(isolate, script->line_offset()->value()),
-        v8::Integer::New(isolate, script->column_offset()->value()));
+        v8::Integer::New(isolate, script->column_offset()->value()),
+        v8::Boolean::New(isolate, script->is_shared_cross_origin()),
+        v8::Integer::New(isolate, script->id()->value()),
+        v8::Boolean::New(isolate, script->is_embedder_debug_script()));
     return origin;
   }
   return v8::ScriptOrigin(Handle<Value>());
index e77dd97..aef9428 100644 (file)
@@ -1448,7 +1448,7 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
     Handle<String> script_name =
         factory->NewStringFromUtf8(name).ToHandleChecked();
     function_info = Compiler::CompileScript(
-        source, script_name, 0, 0, false, top_context, extension, NULL,
+        source, script_name, 0, 0, false, false, top_context, extension, NULL,
         ScriptCompiler::kNoCompileOptions,
         use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
     if (function_info.is_null()) return false;
@@ -1764,7 +1764,7 @@ bool Genesis::InstallNatives() {
     native_context()->set_script_function(*script_fun);
 
     Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
-    Map::EnsureDescriptorSlack(script_map, 14);
+    Map::EnsureDescriptorSlack(script_map, 15);
 
     PropertyAttributes attribs =
         static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
@@ -1892,6 +1892,15 @@ bool Genesis::InstallNatives() {
       script_map->AppendDescriptor(&d);
     }
 
+    Handle<AccessorInfo> script_is_embedder_debug_script =
+        Accessors::ScriptIsEmbedderDebugScriptInfo(isolate(), attribs);
+    {
+      AccessorConstantDescriptor d(
+          Handle<Name>(Name::cast(script_is_embedder_debug_script->name())),
+          script_is_embedder_debug_script, attribs);
+      script_map->AppendDescriptor(&d);
+    }
+
     // Allocate the empty script.
     Handle<Script> script = factory()->NewScript(factory()->empty_string());
     script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
index 6c9f95a..26a2b14 100644 (file)
@@ -111,12 +111,11 @@ CompilationCacheScript::CompilationCacheScript(Isolate* isolate,
 // We only re-use a cached function for some script source code if the
 // script originates from the same place. This is to avoid issues
 // when reporting errors, etc.
-bool CompilationCacheScript::HasOrigin(
-    Handle<SharedFunctionInfo> function_info,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin) {
+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) {
   Handle<Script> script =
       Handle<Script>(Script::cast(function_info->script()), isolate());
   // If the script name isn't set, the boilerplate script should have
@@ -129,6 +128,10 @@ bool CompilationCacheScript::HasOrigin(
   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()) {
+    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.
@@ -142,12 +145,9 @@ bool CompilationCacheScript::HasOrigin(
 // will be cached, but subsequent code from different source / line
 // won't.
 Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
-    Handle<String> source,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin,
-    Handle<Context> context) {
+    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) {
   Object* result = NULL;
   int generation;
 
@@ -162,11 +162,8 @@ Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
             Handle<SharedFunctionInfo>::cast(probe);
         // Break when we've found a suitable shared function info that
         // matches the origin.
-        if (HasOrigin(function_info,
-                      name,
-                      line_offset,
-                      column_offset,
-                      is_shared_cross_origin)) {
+        if (HasOrigin(function_info, name, line_offset, column_offset,
+                      is_embedder_debug_script, is_shared_cross_origin)) {
           result = *function_info;
           break;
         }
@@ -180,11 +177,8 @@ Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
   if (result != NULL) {
     Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result),
                                       isolate());
-    DCHECK(HasOrigin(shared,
-                     name,
-                     line_offset,
-                     column_offset,
-                     is_shared_cross_origin));
+    DCHECK(HasOrigin(shared, name, line_offset, column_offset,
+                     is_embedder_debug_script, is_shared_cross_origin));
     // 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, shared);
@@ -295,16 +289,14 @@ void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) {
 
 
 MaybeHandle<SharedFunctionInfo> CompilationCache::LookupScript(
-    Handle<String> source,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin,
-    Handle<Context> context) {
+    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) {
   if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
 
   return script_.Lookup(source, name, line_offset, column_offset,
-                        is_shared_cross_origin, context);
+                        is_embedder_debug_script, is_shared_cross_origin,
+                        context);
 }
 
 
index a7c84b7..f57db3d 100644 (file)
@@ -72,10 +72,9 @@ class CompilationCacheScript : public CompilationSubCache {
  public:
   CompilationCacheScript(Isolate* isolate, int generations);
 
-  Handle<SharedFunctionInfo> Lookup(Handle<String> source,
-                                    Handle<Object> name,
-                                    int line_offset,
-                                    int column_offset,
+  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,
                                     Handle<Context> context);
   void Put(Handle<String> source,
@@ -83,11 +82,9 @@ class CompilationCacheScript : public CompilationSubCache {
            Handle<SharedFunctionInfo> function_info);
 
  private:
-  bool HasOrigin(Handle<SharedFunctionInfo> function_info,
-                 Handle<Object> name,
-                 int line_offset,
-                 int column_offset,
-                 bool is_shared_cross_origin);
+  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);
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
 };
@@ -150,7 +147,8 @@ class CompilationCache {
   // 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_shared_cross_origin, Handle<Context> context);
+      int column_offset, bool is_embedder_debug_script,
+      bool is_shared_cross_origin, Handle<Context> context);
 
   // Finds the shared function info for a source string for eval in a
   // given context.  Returns an empty handle if the cache doesn't
index f7d3676..978d571 100644 (file)
@@ -1264,7 +1264,8 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
 
 Handle<SharedFunctionInfo> Compiler::CompileScript(
     Handle<String> source, Handle<Object> script_name, int line_offset,
-    int column_offset, bool is_shared_cross_origin, Handle<Context> context,
+    int column_offset, bool is_embedder_debug_script,
+    bool is_shared_cross_origin, Handle<Context> context,
     v8::Extension* extension, ScriptData** cached_data,
     ScriptCompiler::CompileOptions compile_options, NativesFlag natives) {
   Isolate* isolate = source->GetIsolate();
@@ -1292,8 +1293,8 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
   Handle<SharedFunctionInfo> result;
   if (extension == NULL) {
     maybe_result = compilation_cache->LookupScript(
-        source, script_name, line_offset, column_offset, is_shared_cross_origin,
-        context);
+        source, script_name, line_offset, column_offset,
+        is_embedder_debug_script, is_shared_cross_origin, context);
     if (maybe_result.is_null() && FLAG_serialize_toplevel &&
         compile_options == ScriptCompiler::kConsumeCodeCache &&
         !isolate->debug()->is_loaded()) {
@@ -1327,6 +1328,7 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
       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);
 
     // Compile the function and add it to the cache.
     CompilationInfoWithZone info(script);
index f56d40a..9901fe6 100644 (file)
@@ -704,9 +704,9 @@ class Compiler : public AllStatic {
   // 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_shared_cross_origin, Handle<Context> context,
-      v8::Extension* extension, ScriptData** cached_data,
-      ScriptCompiler::CompileOptions compile_options,
+      int column_offset, bool is_debugger_script, bool is_shared_cross_origin,
+      Handle<Context> context, v8::Extension* extension,
+      ScriptData** cached_data, ScriptCompiler::CompileOptions compile_options,
       NativesFlag is_natives_code);
 
   static Handle<SharedFunctionInfo> CompileStreamedScript(CompilationInfo* info,
index dd3ec6e..07ad71b 100644 (file)
@@ -744,7 +744,7 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
   // Compile the script.
   Handle<SharedFunctionInfo> function_info;
   function_info = Compiler::CompileScript(
-      source_code, script_name, 0, 0, false, context, NULL, NULL,
+      source_code, script_name, 0, 0, false, false, context, NULL, NULL,
       ScriptCompiler::kNoCompileOptions, NATIVES_CODE);
 
   // Silently ignore stack overflows during compilation.
index 88ced6c..a0e2a38 100644 (file)
@@ -5607,6 +5607,8 @@ ACCESSORS(Script, eval_from_shared, Object, kEvalFromSharedOffset)
 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)
index 1352801..93c3928 100644 (file)
@@ -6596,6 +6596,12 @@ class Script: public Struct {
   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
@@ -6652,7 +6658,8 @@ class Script: public Struct {
   // Bit positions in the flags field.
   static const int kCompilationTypeBit = 0;
   static const int kCompilationStateBit = 1;
-  static const int kIsSharedCrossOriginBit = 2;
+  static const int kIsEmbedderDebugScriptBit = 2;
+  static const int kIsSharedCrossOriginBit = 3;
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
 };
index 117caf2..b21965d 100644 (file)
@@ -32,7 +32,7 @@ static Handle<JSFunction> Compile(const char* source) {
                                    ->NewStringFromUtf8(CStrVector(source))
                                    .ToHandleChecked();
   Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
-      source_code, Handle<String>(), 0, 0, false,
+      source_code, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, NULL,
       v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
   return isolate->factory()->NewFunctionFromSharedFunctionInfo(
index c39c2f8..6306db9 100644 (file)
@@ -4598,6 +4598,8 @@ TEST(MessageHandler2) {
 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_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
   message_received = true;
 }
@@ -4611,10 +4613,9 @@ TEST(MessageHandler3) {
   v8::V8::AddMessageListener(check_message_3);
   LocalContext context;
   v8::ScriptOrigin origin =
-      v8::ScriptOrigin(v8_str("6.75"),
-                       v8::Integer::New(isolate, 1),
-                       v8::Integer::New(isolate, 2),
-                       v8::True(isolate));
+      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::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"),
                                                   &origin);
   script->Run();
@@ -19327,8 +19328,11 @@ TEST(Regress528) {
 THREADED_TEST(ScriptOrigin) {
   LocalContext env;
   v8::HandleScope scope(env->GetIsolate());
-  v8::ScriptOrigin origin =
-      v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"));
+  v8::ScriptOrigin origin = v8::ScriptOrigin(
+      v8::String::NewFromUtf8(env->GetIsolate(), "test"),
+      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::Handle<v8::String> script = v8::String::NewFromUtf8(
       env->GetIsolate(), "function f() {}\n\nfunction g() {}");
   v8::Script::Compile(script, &origin)->Run();
@@ -19339,11 +19343,15 @@ THREADED_TEST(ScriptOrigin) {
 
   v8::ScriptOrigin script_origin_f = f->GetScriptOrigin();
   CHECK_EQ("test", *v8::String::Utf8Value(script_origin_f.ResourceName()));
-  CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value());
+  CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value());
+  CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value());
+  CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value());
 
   v8::ScriptOrigin script_origin_g = g->GetScriptOrigin();
   CHECK_EQ("test", *v8::String::Utf8Value(script_origin_g.ResourceName()));
-  CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value());
+  CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value());
+  CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value());
+  CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value());
 }
 
 
index a05231e..9982a55 100644 (file)
@@ -60,7 +60,7 @@ static Handle<JSFunction> Compile(const char* source) {
   Handle<String> source_code = isolate->factory()->NewStringFromUtf8(
       CStrVector(source)).ToHandleChecked();
   Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
-      source_code, Handle<String>(), 0, 0, false,
+      source_code, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, NULL,
       v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
   return isolate->factory()->NewFunctionFromSharedFunctionInfo(
index 8295839..ed80bd6 100644 (file)
@@ -1407,7 +1407,7 @@ TEST(CompilationCacheCachingBehavior) {
   // 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, true, native_context);
+      source, Handle<Object>(), 0, 0, false, true, native_context);
   CHECK(info.is_null());
 
   {
@@ -1417,16 +1417,16 @@ TEST(CompilationCacheCachingBehavior) {
 
   // 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, true,
-                                         native_context);
+  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
+                                         true, native_context);
   CHECK(!info.is_null());
 
   heap->CollectAllGarbage(Heap::kNoGCFlags);
 
   // 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, true,
-                                         native_context);
+  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
+                                         true, native_context);
   CHECK(!info.is_null());
 
   while (!info.ToHandleChecked()->code()->IsOld()) {
@@ -1435,8 +1435,8 @@ TEST(CompilationCacheCachingBehavior) {
 
   heap->CollectAllGarbage(Heap::kNoGCFlags);
   // Ensure code aging cleared the entry from the cache.
-  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, true,
-                                         native_context);
+  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
+                                         true, native_context);
   CHECK(info.is_null());
 
   {
@@ -1446,8 +1446,8 @@ TEST(CompilationCacheCachingBehavior) {
 
   // 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, true,
-                                         native_context);
+  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
+                                         true, native_context);
   CHECK(info.is_null());
 
   for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) {
@@ -1461,8 +1461,8 @@ TEST(CompilationCacheCachingBehavior) {
 
   // 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, true,
-                                         native_context);
+  info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
+                                         true, native_context);
   CHECK(info.is_null());
 }
 
index 354bc7c..e6ae75a 100644 (file)
@@ -754,7 +754,7 @@ TEST(SerializeToplevelOnePlusOne) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      orig_source, Handle<String>(), 0, 0, false,
+      orig_source, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -764,7 +764,7 @@ TEST(SerializeToplevelOnePlusOne) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        copy_source, Handle<String>(), 0, 0, false,
+        copy_source, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -809,7 +809,7 @@ TEST(SerializeToplevelInternalizedString) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      orig_source, Handle<String>(), 0, 0, false,
+      orig_source, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
   Handle<JSFunction> orig_fun =
@@ -825,7 +825,7 @@ TEST(SerializeToplevelInternalizedString) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        copy_source, Handle<String>(), 0, 0, false,
+        copy_source, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -868,7 +868,7 @@ TEST(SerializeToplevelLargeCodeObject) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_str, Handle<String>(), 0, 0, false,
+      source_str, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -878,7 +878,7 @@ TEST(SerializeToplevelLargeCodeObject) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_str, Handle<String>(), 0, 0, false,
+        source_str, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -924,7 +924,7 @@ TEST(SerializeToplevelLargeStrings) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_str, Handle<String>(), 0, 0, false,
+      source_str, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -932,7 +932,7 @@ TEST(SerializeToplevelLargeStrings) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_str, Handle<String>(), 0, 0, false,
+        source_str, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -997,7 +997,7 @@ TEST(SerializeToplevelThreeBigStrings) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_str, Handle<String>(), 0, 0, false,
+      source_str, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -1005,7 +1005,7 @@ TEST(SerializeToplevelThreeBigStrings) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_str, Handle<String>(), 0, 0, false,
+        source_str, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -1105,7 +1105,7 @@ TEST(SerializeToplevelExternalString) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_string, Handle<String>(), 0, 0, false,
+      source_string, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -1113,7 +1113,7 @@ TEST(SerializeToplevelExternalString) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_string, Handle<String>(), 0, 0, false,
+        source_string, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -1167,7 +1167,7 @@ TEST(SerializeToplevelLargeExternalString) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_str, Handle<String>(), 0, 0, false,
+      source_str, Handle<String>(), 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -1175,7 +1175,7 @@ TEST(SerializeToplevelLargeExternalString) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_str, Handle<String>(), 0, 0, false,
+        source_str, Handle<String>(), 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }
@@ -1221,7 +1221,7 @@ TEST(SerializeToplevelExternalScriptName) {
   ScriptData* cache = NULL;
 
   Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
-      source_string, name, 0, 0, false,
+      source_string, name, 0, 0, false, false,
       Handle<Context>(isolate->native_context()), NULL, &cache,
       v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
 
@@ -1229,7 +1229,7 @@ TEST(SerializeToplevelExternalScriptName) {
   {
     DisallowCompilation no_compile_expected(isolate);
     copy = Compiler::CompileScript(
-        source_string, name, 0, 0, false,
+        source_string, name, 0, 0, false, false,
         Handle<Context>(isolate->native_context()), NULL, &cache,
         v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
   }