| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/code-generator.h" | 8 #include "src/compiler/code-generator.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "test/cctest/compiler/c-signature.h" | 24 #include "test/cctest/compiler/c-signature.h" |
| 25 #include "test/cctest/compiler/function-tester.h" | 25 #include "test/cctest/compiler/function-tester.h" |
| 26 | 26 |
| 27 using namespace v8::internal; | 27 using namespace v8::internal; |
| 28 using namespace v8::internal::compiler; | 28 using namespace v8::internal::compiler; |
| 29 | 29 |
| 30 | 30 |
| 31 #if V8_TURBOFAN_TARGET | 31 #if V8_TURBOFAN_TARGET |
| 32 | 32 |
| 33 typedef RawMachineAssembler::Label MLabel; | 33 typedef RawMachineAssembler::Label MLabel; |
| 34 typedef v8::internal::compiler::InstructionSequence TestInstrSeq; |
| 34 | 35 |
| 35 static Handle<JSFunction> NewFunction(const char* source) { | 36 static Handle<JSFunction> NewFunction(const char* source) { |
| 36 return v8::Utils::OpenHandle( | 37 return v8::Utils::OpenHandle( |
| 37 *v8::Handle<v8::Function>::Cast(CompileRun(source))); | 38 *v8::Handle<v8::Function>::Cast(CompileRun(source))); |
| 38 } | 39 } |
| 39 | 40 |
| 40 | 41 |
| 41 class DeoptCodegenTester { | 42 class DeoptCodegenTester { |
| 42 public: | 43 public: |
| 43 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) | 44 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 59 | 60 |
| 60 void GenerateCodeFromSchedule(Schedule* schedule) { | 61 void GenerateCodeFromSchedule(Schedule* schedule) { |
| 61 OFStream os(stdout); | 62 OFStream os(stdout); |
| 62 if (FLAG_trace_turbo) { | 63 if (FLAG_trace_turbo) { |
| 63 os << *schedule; | 64 os << *schedule; |
| 64 } | 65 } |
| 65 | 66 |
| 66 // Initialize the codegen and generate code. | 67 // Initialize the codegen and generate code. |
| 67 Linkage* linkage = new (scope_->main_zone()) Linkage(info.zone(), &info); | 68 Linkage* linkage = new (scope_->main_zone()) Linkage(info.zone(), &info); |
| 68 InstructionBlocks* instruction_blocks = | 69 InstructionBlocks* instruction_blocks = |
| 69 InstructionSequence::InstructionBlocksFor(scope_->main_zone(), | 70 TestInstrSeq::InstructionBlocksFor(scope_->main_zone(), schedule); |
| 70 schedule); | 71 code = new TestInstrSeq::InstructionSequence(scope_->main_zone(), |
| 71 code = new v8::internal::compiler::InstructionSequence(scope_->main_zone(), | 72 instruction_blocks); |
| 72 instruction_blocks); | |
| 73 SourcePositionTable source_positions(graph); | 73 SourcePositionTable source_positions(graph); |
| 74 InstructionSelector selector(scope_->main_zone(), graph, linkage, code, | 74 InstructionSelector selector(scope_->main_zone(), graph, linkage, code, |
| 75 schedule, &source_positions); | 75 schedule, &source_positions); |
| 76 selector.SelectInstructions(); | 76 selector.SelectInstructions(); |
| 77 | 77 |
| 78 if (FLAG_trace_turbo) { | 78 if (FLAG_trace_turbo) { |
| 79 os << "----- Instruction sequence before register allocation -----\n" | 79 os << "----- Instruction sequence before register allocation -----\n" |
| 80 << *code; | 80 << *code; |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 100 #endif | 100 #endif |
| 101 } | 101 } |
| 102 | 102 |
| 103 Zone* zone() { return scope_->main_zone(); } | 103 Zone* zone() { return scope_->main_zone(); } |
| 104 | 104 |
| 105 HandleAndZoneScope* scope_; | 105 HandleAndZoneScope* scope_; |
| 106 Handle<JSFunction> function; | 106 Handle<JSFunction> function; |
| 107 CompilationInfo info; | 107 CompilationInfo info; |
| 108 BailoutId bailout_id; | 108 BailoutId bailout_id; |
| 109 Handle<Code> result_code; | 109 Handle<Code> result_code; |
| 110 v8::internal::compiler::InstructionSequence* code; | 110 TestInstrSeq* code; |
| 111 Graph* graph; | 111 Graph* graph; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 | 114 |
| 115 class TrivialDeoptCodegenTester : public DeoptCodegenTester { | 115 class TrivialDeoptCodegenTester : public DeoptCodegenTester { |
| 116 public: | 116 public: |
| 117 explicit TrivialDeoptCodegenTester(HandleAndZoneScope* scope) | 117 explicit TrivialDeoptCodegenTester(HandleAndZoneScope* scope) |
| 118 : DeoptCodegenTester(scope, | 118 : DeoptCodegenTester(scope, |
| 119 "function foo() { deopt(); return 42; }; foo") {} | 119 "function foo() { deopt(); return 42; }; foo") {} |
| 120 | 120 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 Handle<Object> result; | 312 Handle<Object> result; |
| 313 bool has_pending_exception = | 313 bool has_pending_exception = |
| 314 !Execution::Call(isolate, t.function, | 314 !Execution::Call(isolate, t.function, |
| 315 isolate->factory()->undefined_value(), 0, NULL, | 315 isolate->factory()->undefined_value(), 0, NULL, |
| 316 false).ToHandle(&result); | 316 false).ToHandle(&result); |
| 317 CHECK(!has_pending_exception); | 317 CHECK(!has_pending_exception); |
| 318 CHECK(result->SameValue(Smi::FromInt(42))); | 318 CHECK(result->SameValue(Smi::FromInt(42))); |
| 319 } | 319 } |
| 320 | 320 |
| 321 #endif | 321 #endif |
| OLD | NEW |