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
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1443
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
{ // --- 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();
// 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);
}
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);
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);
}
}
// 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);