Chromium Code Reviews

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1372293005: [Interpreter] Support top-level code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/interpreter-assembler.h" 9 #include "src/compiler/interpreter-assembler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 41 matching lines...)
52 Handle<Code> code = assembler.GenerateCode(); \ 52 Handle<Code> code = assembler.GenerateCode(); \
53 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \ 53 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \
54 } 54 }
55 BYTECODE_LIST(GENERATE_CODE) 55 BYTECODE_LIST(GENERATE_CODE)
56 #undef GENERATE_CODE 56 #undef GENERATE_CODE
57 } 57 }
58 } 58 }
59 59
60 60
61 bool Interpreter::MakeBytecode(CompilationInfo* info) { 61 bool Interpreter::MakeBytecode(CompilationInfo* info) {
62 Handle<SharedFunctionInfo> shared_info = info->shared_info();
63
64 BytecodeGenerator generator(info->isolate(), info->zone()); 62 BytecodeGenerator generator(info->isolate(), info->zone());
65 info->EnsureFeedbackVector(); 63 info->EnsureFeedbackVector();
66 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); 64 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info);
67 if (FLAG_print_bytecode) { 65 if (FLAG_print_bytecode) {
68 bytecodes->Print(); 66 bytecodes->Print();
69 } 67 }
70 68
71 DCHECK(shared_info->function_data()->IsUndefined()); 69 info->SetBytecodeArray(bytecodes);
72 if (!shared_info->function_data()->IsUndefined()) {
73 return false;
74 }
75
76 shared_info->set_function_data(*bytecodes);
77 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); 70 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline());
78 return true; 71 return true;
79 } 72 }
80 73
81 74
82 bool Interpreter::IsInterpreterTableInitialized( 75 bool Interpreter::IsInterpreterTableInitialized(
83 Handle<FixedArray> handler_table) { 76 Handle<FixedArray> handler_table) {
84 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); 77 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1);
85 return handler_table->get(0) != isolate_->heap()->undefined_value(); 78 return handler_table->get(0) != isolate_->heap()->undefined_value();
86 } 79 }
(...skipping 439 matching lines...)
526 // 519 //
527 // Return the value in register 0. 520 // Return the value in register 0.
528 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 521 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
529 __ Return(); 522 __ Return();
530 } 523 }
531 524
532 525
533 } // namespace interpreter 526 } // namespace interpreter
534 } // namespace internal 527 } // namespace internal
535 } // namespace v8 528 } // namespace v8
OLDNEW

Powered by Google App Engine