diff options
Diffstat (limited to 'deps/v8/src/full-codegen.cc')
-rw-r--r-- | deps/v8/src/full-codegen.cc | 133 |
1 files changed, 67 insertions, 66 deletions
diff --git a/deps/v8/src/full-codegen.cc b/deps/v8/src/full-codegen.cc index 9b1df4ee7..44fe011a4 100644 --- a/deps/v8/src/full-codegen.cc +++ b/deps/v8/src/full-codegen.cc @@ -316,6 +316,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { code->set_optimizable(info->IsOptimizable() && !info->function()->flags()->Contains(kDontOptimize) && info->function()->scope()->AllowsLazyRecompilation()); + code->set_self_optimization_header(cgen.has_self_optimization_header_); cgen.PopulateDeoptimizationData(code); cgen.PopulateTypeFeedbackInfo(code); cgen.PopulateTypeFeedbackCells(code); @@ -331,6 +332,9 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { code->set_stack_check_table_offset(table_offset); CodeGenerator::PrintCode(code, info); info->SetCode(code); // May be an empty handle. + if (!code.is_null()) { + isolate->runtime_profiler()->NotifyCodeGenerated(code->instruction_size()); + } #ifdef ENABLE_GDB_JIT_INTERFACE if (FLAG_gdbjit && !code.is_null()) { GDBJITLineInfo* lineinfo = @@ -569,91 +573,88 @@ void FullCodeGenerator::DoTest(const TestContext* context) { void FullCodeGenerator::VisitDeclarations( ZoneList<Declaration*>* declarations) { - ZoneList<Handle<Object> >* saved_globals = globals_; - ZoneList<Handle<Object> > inner_globals(10); - globals_ = &inner_globals; + int save_global_count = global_count_; + global_count_ = 0; AstVisitor::VisitDeclarations(declarations); - if (!globals_->is_empty()) { + + // Batch declare global functions and variables. + if (global_count_ > 0) { + Handle<FixedArray> array = + isolate()->factory()->NewFixedArray(2 * global_count_, TENURED); + int length = declarations->length(); + for (int j = 0, i = 0; i < length; i++) { + Declaration* decl = declarations->at(i); + Variable* var = decl->proxy()->var(); + + if (var->IsUnallocated()) { + array->set(j++, *(var->name())); + FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration(); + if (fun_decl == NULL) { + if (var->binding_needs_init()) { + // In case this binding needs initialization use the hole. + array->set_the_hole(j++); + } else { + array->set_undefined(j++); + } + } else { + Handle<SharedFunctionInfo> function = + Compiler::BuildFunctionInfo(fun_decl->fun(), script()); + // Check for stack-overflow exception. + if (function.is_null()) { + SetStackOverflow(); + return; + } + array->set(j++, *function); + } + } + } // Invoke the platform-dependent code generator to do the actual // declaration the global functions and variables. - Handle<FixedArray> array = - isolate()->factory()->NewFixedArray(globals_->length(), TENURED); - for (int i = 0; i < globals_->length(); ++i) - array->set(i, *globals_->at(i)); DeclareGlobals(array); } - globals_ = saved_globals; + global_count_ = save_global_count; } -void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) { - Handle<JSModule> instance = module->interface()->Instance(); - ASSERT(!instance.is_null()); +void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { + EmitDeclaration(decl->proxy(), decl->mode(), NULL); +} - // Allocate a module context statically. - Block* block = module->body(); - Scope* saved_scope = scope(); - scope_ = block->scope(); - Handle<ScopeInfo> scope_info = scope_->GetScopeInfo(); - - // Generate code for module creation and linking. - Comment cmnt(masm_, "[ ModuleLiteral"); - SetStatementPosition(block); - - if (scope_info->HasContext()) { - // Set up module context. - __ Push(scope_info); - __ Push(instance); - __ CallRuntime(Runtime::kPushModuleContext, 2); - StoreToFrameField( - StandardFrameConstants::kContextOffset, context_register()); - } - { - Comment cmnt(masm_, "[ Declarations"); - VisitDeclarations(scope_->declarations()); - } +void FullCodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { + EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); +} - scope_ = saved_scope; - if (scope_info->HasContext()) { - // Pop module context. - LoadContextField(context_register(), Context::PREVIOUS_INDEX); - // Update local stack frame context field. - StoreToFrameField( - StandardFrameConstants::kContextOffset, context_register()); - } - // Populate module instance object. - const PropertyAttributes attr = - static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE | DONT_ENUM); - for (Interface::Iterator it = module->interface()->iterator(); - !it.done(); it.Advance()) { - if (it.interface()->IsModule()) { - Handle<Object> value = it.interface()->Instance(); - ASSERT(!value.is_null()); - JSReceiver::SetProperty(instance, it.name(), value, attr, kStrictMode); - } else { - // TODO(rossberg): set proper getters instead of undefined... - // instance->DefineAccessor(*it.name(), ACCESSOR_GETTER, *getter, attr); - Handle<Object> value(isolate()->heap()->undefined_value()); - JSReceiver::SetProperty(instance, it.name(), value, attr, kStrictMode); - } - } - USE(instance->PreventExtensions()); +void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* decl) { + EmitDeclaration(decl->proxy(), decl->mode(), NULL); +} + + +void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { + EmitDeclaration(decl->proxy(), decl->mode(), NULL); +} + + +void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { + // TODO(rossberg) +} + + +void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) { + // TODO(rossberg) } void FullCodeGenerator::VisitModuleVariable(ModuleVariable* module) { - // Noting to do. - // The instance object is resolved statically through the module's interface. + // TODO(rossberg) } void FullCodeGenerator::VisitModulePath(ModulePath* module) { - // Noting to do. - // The instance object is resolved statically through the module's interface. + // TODO(rossberg) } @@ -915,9 +916,9 @@ void FullCodeGenerator::VisitBlock(Block* stmt) { Scope* saved_scope = scope(); // Push a block context when entering a block with block scoped variables. - if (stmt->scope() != NULL) { + if (stmt->block_scope() != NULL) { { Comment cmnt(masm_, "[ Extend block context"); - scope_ = stmt->scope(); + scope_ = stmt->block_scope(); Handle<ScopeInfo> scope_info = scope_->GetScopeInfo(); int heap_slots = scope_info->ContextLength() - Context::MIN_CONTEXT_SLOTS; __ Push(scope_info); @@ -944,7 +945,7 @@ void FullCodeGenerator::VisitBlock(Block* stmt) { PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); // Pop block context if necessary. - if (stmt->scope() != NULL) { + if (stmt->block_scope() != NULL) { LoadContextField(context_register(), Context::PREVIOUS_INDEX); // Update local stack frame context field. StoreToFrameField(StandardFrameConstants::kContextOffset, |