| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 typedef RawMachineAssembler::Label MLabel; | 33 typedef RawMachineAssembler::Label MLabel; |
| 34 typedef v8::internal::compiler::InstructionSequence TestInstrSeq; | 34 typedef v8::internal::compiler::InstructionSequence TestInstrSeq; |
| 35 | 35 |
| 36 static Handle<JSFunction> NewFunction(const char* source) { | 36 static Handle<JSFunction> NewFunction(const char* source) { |
| 37 return v8::Utils::OpenHandle( | 37 return v8::Utils::OpenHandle( |
| 38 *v8::Handle<v8::Function>::Cast(CompileRun(source))); | 38 *v8::Handle<v8::Function>::Cast(CompileRun(source))); |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 static ParseInfo* InitParseInfo(ParseInfo* info, Handle<JSFunction> function) { |
| 43 info->InitializeFromJSFunction(function); |
| 44 return info; |
| 45 } |
| 46 |
| 47 |
| 42 class DeoptCodegenTester { | 48 class DeoptCodegenTester { |
| 43 public: | 49 public: |
| 44 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) | 50 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) |
| 45 : scope_(scope), | 51 : scope_(scope), |
| 46 function(NewFunction(src)), | 52 function(NewFunction(src)), |
| 47 info(function, scope->main_zone()), | 53 parse_info(scope->main_zone()), |
| 54 info(InitParseInfo(&parse_info, function)), |
| 48 bailout_id(-1) { | 55 bailout_id(-1) { |
| 49 CHECK(Parser::ParseStatic(&info)); | 56 CHECK(Parser::ParseStatic(&parse_info)); |
| 50 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 57 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 51 CHECK(Compiler::Analyze(&info)); | 58 CHECK(Compiler::Analyze(&parse_info)); |
| 52 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 59 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 53 | 60 |
| 54 DCHECK(info.shared_info()->has_deoptimization_support()); | 61 DCHECK(info.shared_info()->has_deoptimization_support()); |
| 55 | 62 |
| 56 graph = new (scope_->main_zone()) Graph(scope_->main_zone()); | 63 graph = new (scope_->main_zone()) Graph(scope_->main_zone()); |
| 57 } | 64 } |
| 58 | 65 |
| 59 virtual ~DeoptCodegenTester() {} | 66 virtual ~DeoptCodegenTester() {} |
| 60 | 67 |
| 61 void GenerateCodeFromSchedule(Schedule* schedule) { | 68 void GenerateCodeFromSchedule(Schedule* schedule) { |
| 62 OFStream os(stdout); | 69 OFStream os(stdout); |
| 63 if (FLAG_trace_turbo) { | 70 if (FLAG_trace_turbo) { |
| 64 os << *schedule; | 71 os << *schedule; |
| 65 } | 72 } |
| 66 result_code = Pipeline::GenerateCodeForTesting(&info, graph, schedule); | 73 result_code = Pipeline::GenerateCodeForTesting(&info, graph, schedule); |
| 67 #ifdef OBJECT_PRINT | 74 #ifdef OBJECT_PRINT |
| 68 if (FLAG_print_opt_code || FLAG_trace_turbo) { | 75 if (FLAG_print_opt_code || FLAG_trace_turbo) { |
| 69 result_code->Print(); | 76 result_code->Print(); |
| 70 } | 77 } |
| 71 #endif | 78 #endif |
| 72 } | 79 } |
| 73 | 80 |
| 74 Zone* zone() { return scope_->main_zone(); } | 81 Zone* zone() { return scope_->main_zone(); } |
| 75 Isolate* isolate() { return scope_->main_isolate(); } | 82 Isolate* isolate() { return scope_->main_isolate(); } |
| 76 | 83 |
| 77 HandleAndZoneScope* scope_; | 84 HandleAndZoneScope* scope_; |
| 78 Handle<JSFunction> function; | 85 Handle<JSFunction> function; |
| 86 ParseInfo parse_info; |
| 79 CompilationInfo info; | 87 CompilationInfo info; |
| 80 BailoutId bailout_id; | 88 BailoutId bailout_id; |
| 81 Handle<Code> result_code; | 89 Handle<Code> result_code; |
| 82 TestInstrSeq* code; | 90 TestInstrSeq* code; |
| 83 Graph* graph; | 91 Graph* graph; |
| 84 }; | 92 }; |
| 85 | 93 |
| 86 | 94 |
| 87 class TrivialDeoptCodegenTester : public DeoptCodegenTester { | 95 class TrivialDeoptCodegenTester : public DeoptCodegenTester { |
| 88 public: | 96 public: |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 Handle<Object> result; | 292 Handle<Object> result; |
| 285 bool has_pending_exception = | 293 bool has_pending_exception = |
| 286 !Execution::Call(isolate, t.function, | 294 !Execution::Call(isolate, t.function, |
| 287 isolate->factory()->undefined_value(), 0, NULL, | 295 isolate->factory()->undefined_value(), 0, NULL, |
| 288 false).ToHandle(&result); | 296 false).ToHandle(&result); |
| 289 CHECK(!has_pending_exception); | 297 CHECK(!has_pending_exception); |
| 290 CHECK(result->SameValue(Smi::FromInt(42))); | 298 CHECK(result->SameValue(Smi::FromInt(42))); |
| 291 } | 299 } |
| 292 | 300 |
| 293 #endif | 301 #endif |
| OLD | NEW |