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 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1443 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
2e34b0354e
commit
747e20c449
@ -518,10 +518,11 @@ void Genesis::CreateRoots(v8::Handle<v8::ObjectTemplate> global_template,
|
||||
{ // --- 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 @@ bool Genesis::InstallNatives() {
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
10
src/d8.cc
10
src/d8.cc
@ -351,7 +351,15 @@ void Shell::Initialize() {
|
||||
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);
|
||||
|
@ -5718,17 +5718,13 @@ static int DebugGetLoadedScripts(FixedArray* instances, int instances_size) {
|
||||
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);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ for (i = 0; i < scripts.length; i++) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
Loading…
Reference in New Issue
Block a user