Reviewers: Mads Ager,

Description:
Mark the empty script object, the script for the empty function and the
D8 utility script as native scripts.

This is mainly to avoid these scripts showing up in the debugger when
showing normal scripts.

Removed the check for the empty script in the debugger function
returning loaded scripts as this check only filtered out the empty
script from the debugger context and not empty scripts in all other
contexts. Also this filter did not take the script for the empty
function into account.

Please review this at http://codereview.chromium.org/39322

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/bootstrapper.cc
   M     src/d8.cc
   M     src/runtime.cc
   M     test/mjsunit/debug-script.js


Index: test/mjsunit/debug-script.js
===================================================================
--- test/mjsunit/debug-script.js        (revision 1441)
+++ test/mjsunit/debug-script.js        (working copy)
@@ -54,7 +54,7 @@
  }

  // This has to be updated if the number of native scripts change.
-assertEquals(12, native_count);
+assertEquals(16, native_count);
  // If no snapshot is used, only the 'gc' extension is loaded.
  // If snapshot is used, all extensions are cached in the snapshot.
  assertTrue(extension_count == 1 || extension_count == 5);
Index: src/bootstrapper.cc
===================================================================
--- src/bootstrapper.cc (revision 1441)
+++ src/bootstrapper.cc (working copy)
@@ -518,10 +518,11 @@
    {  // --- E m p t y ---
      Handle<Code> code =
          Handle<Code>(Builtins::builtin(Builtins::EmptyFunction));
+    empty_function->set_code(*code);
      Handle<String> source = Factory::NewStringFromAscii(CStrVector("()  
{}"));
-
-    empty_function->set_code(*code);
-    empty_function->shared()->set_script(*Factory::NewScript(source));
+    Handle<Script> script = Factory::NewScript(source);
+    script->set_type(Smi::FromInt(SCRIPT_TYPE_NATIVE));
+    empty_function->shared()->set_script(*script);
      empty_function->shared()->set_start_position(0);
      empty_function->shared()->set_end_position(source->length());
      empty_function->shared()->DontAdaptArguments();
@@ -1028,6 +1029,7 @@

      // Allocate the empty script.
      Handle<Script> script = Factory::NewScript(Factory::empty_string());
+    script->set_type(Smi::FromInt(SCRIPT_TYPE_NATIVE));
      global_context()->set_empty_script(*script);
    }

Index: src/runtime.cc
===================================================================
--- src/runtime.cc      (revision 1441)
+++ src/runtime.cc      (working copy)
@@ -5718,17 +5718,13 @@
    NoHandleAllocation ha;
    AssertNoAllocation no_alloc;

-  // Get hold of the current empty script.
-  Context* context = Top::context()->global_context();
-  Script* empty = context->empty_script();
-
    // Scan heap for Script objects.
    int count = 0;
    HeapIterator iterator;
    while (iterator.has_next()) {
      HeapObject* obj = iterator.next();
      ASSERT(obj != NULL);
-    if (obj->IsScript() && obj != empty) {
+    if (obj->IsScript()) {
        if (instances != NULL && count < instances_size) {
          instances->set(count, obj);
        }
Index: src/d8.cc
===================================================================
--- src/d8.cc   (revision 1441)
+++ src/d8.cc   (working copy)
@@ -351,8 +351,16 @@
                                        shell_source.length());
    Handle<String> name = String::New(shell_source_name.start(),
                                      shell_source_name.length());
-  Script::Compile(source, name)->Run();
+  Handle<Script> script = Script::Compile(source, name);
+  script->Run();

+  // Mark the d8 shell script as native to avoid it showing up as normal  
source
+  // in the debugger.
+  i::Handle<i::JSFunction> script_fun = Utils::OpenHandle(*script);
+  i::Handle<i::Script> script_object =
+       
i::Handle<i::Script>(i::Script::cast(script_fun->shared()->script()));
+  script_object->set_type(i::Smi::FromInt(i::SCRIPT_TYPE_NATIVE));
+
    // Create the evaluation context
    evaluation_context_ = Context::New(NULL, global_template);
    evaluation_context_->SetSecurityToken(Undefined());



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to