Author: [email protected]
Date: Mon Mar  9 01:44:59 2009
New Revision: 1443

Modified:
    branches/bleeding_edge/src/bootstrapper.cc
    branches/bleeding_edge/src/d8.cc
    branches/bleeding_edge/src/runtime.cc
    branches/bleeding_edge/test/mjsunit/debug-script.js

Log:
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.
Review URL: http://codereview.chromium.org/39322

Modified: branches/bleeding_edge/src/bootstrapper.cc
==============================================================================
--- branches/bleeding_edge/src/bootstrapper.cc  (original)
+++ branches/bleeding_edge/src/bootstrapper.cc  Mon Mar  9 01:44:59 2009
@@ -518,10 +518,11 @@
    {  // --- E m p t y ---
      Handle<Code> code =
          Handle<Code>(Builtins::builtin(Builtins::EmptyFunction));
-    Handle<String> source = Factory::NewStringFromAscii(CStrVector("()  
{}"));
-
      empty_function->set_code(*code);
-    empty_function->shared()->set_script(*Factory::NewScript(source));
+    Handle<String> source = Factory::NewStringFromAscii(CStrVector("()  
{}"));
+    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);
    }


Modified: branches/bleeding_edge/src/d8.cc
==============================================================================
--- branches/bleeding_edge/src/d8.cc    (original)
+++ branches/bleeding_edge/src/d8.cc    Mon Mar  9 01:44:59 2009
@@ -351,7 +351,15 @@
                                        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);

Modified: branches/bleeding_edge/src/runtime.cc
==============================================================================
--- branches/bleeding_edge/src/runtime.cc       (original)
+++ branches/bleeding_edge/src/runtime.cc       Mon Mar  9 01:44:59 2009
@@ -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);
        }

Modified: branches/bleeding_edge/test/mjsunit/debug-script.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/debug-script.js (original)
+++ branches/bleeding_edge/test/mjsunit/debug-script.js Mon Mar  9 01:44:59  
2009
@@ -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);

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

Reply via email to