| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65     } | 65     } | 
| 66     result_code = Pipeline::GenerateCodeForTesting(&info, graph, schedule); | 66     result_code = Pipeline::GenerateCodeForTesting(&info, graph, schedule); | 
| 67 #ifdef OBJECT_PRINT | 67 #ifdef OBJECT_PRINT | 
| 68     if (FLAG_print_opt_code || FLAG_trace_turbo) { | 68     if (FLAG_print_opt_code || FLAG_trace_turbo) { | 
| 69       result_code->Print(); | 69       result_code->Print(); | 
| 70     } | 70     } | 
| 71 #endif | 71 #endif | 
| 72   } | 72   } | 
| 73 | 73 | 
| 74   Zone* zone() { return scope_->main_zone(); } | 74   Zone* zone() { return scope_->main_zone(); } | 
|  | 75   Isolate* isolate() { return scope_->main_isolate(); } | 
| 75 | 76 | 
| 76   HandleAndZoneScope* scope_; | 77   HandleAndZoneScope* scope_; | 
| 77   Handle<JSFunction> function; | 78   Handle<JSFunction> function; | 
| 78   CompilationInfo info; | 79   CompilationInfo info; | 
| 79   BailoutId bailout_id; | 80   BailoutId bailout_id; | 
| 80   Handle<Code> result_code; | 81   Handle<Code> result_code; | 
| 81   TestInstrSeq* code; | 82   TestInstrSeq* code; | 
| 82   Graph* graph; | 83   Graph* graph; | 
| 83 }; | 84 }; | 
| 84 | 85 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 95 | 96 | 
| 96   Schedule* BuildGraphAndSchedule(Graph* graph) { | 97   Schedule* BuildGraphAndSchedule(Graph* graph) { | 
| 97     CommonOperatorBuilder common(zone()); | 98     CommonOperatorBuilder common(zone()); | 
| 98 | 99 | 
| 99     // Manually construct a schedule for the function below: | 100     // Manually construct a schedule for the function below: | 
| 100     // function foo() { | 101     // function foo() { | 
| 101     //   deopt(); | 102     //   deopt(); | 
| 102     // } | 103     // } | 
| 103 | 104 | 
| 104     CSignature1<Object*, Object*> sig; | 105     CSignature1<Object*, Object*> sig; | 
| 105     RawMachineAssembler m(graph, &sig); | 106     RawMachineAssembler m(isolate(), graph, &sig); | 
| 106 | 107 | 
| 107     Handle<JSFunction> deopt_function = | 108     Handle<JSFunction> deopt_function = | 
| 108         NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); | 109         NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); | 
| 109     Unique<JSFunction> deopt_fun_constant = | 110     Unique<JSFunction> deopt_fun_constant = | 
| 110         Unique<JSFunction>::CreateUninitialized(deopt_function); | 111         Unique<JSFunction>::CreateUninitialized(deopt_function); | 
| 111     Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); | 112     Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); | 
| 112 | 113 | 
| 113     Handle<Context> caller_context(function->context(), CcTest::i_isolate()); | 114     Handle<Context> caller_context(function->context(), CcTest::i_isolate()); | 
| 114     Unique<Context> caller_context_constant = | 115     Unique<Context> caller_context_constant = | 
| 115         Unique<Context>::CreateUninitialized(caller_context); | 116         Unique<Context>::CreateUninitialized(caller_context); | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213 | 214 | 
| 214   Schedule* BuildGraphAndSchedule(Graph* graph) { | 215   Schedule* BuildGraphAndSchedule(Graph* graph) { | 
| 215     CommonOperatorBuilder common(zone()); | 216     CommonOperatorBuilder common(zone()); | 
| 216 | 217 | 
| 217     // Manually construct a schedule for the function below: | 218     // Manually construct a schedule for the function below: | 
| 218     // function foo() { | 219     // function foo() { | 
| 219     //   %DeoptimizeFunction(foo); | 220     //   %DeoptimizeFunction(foo); | 
| 220     // } | 221     // } | 
| 221 | 222 | 
| 222     CSignature1<Object*, Object*> sig; | 223     CSignature1<Object*, Object*> sig; | 
| 223     RawMachineAssembler m(graph, &sig); | 224     RawMachineAssembler m(isolate(), graph, &sig); | 
| 224 | 225 | 
| 225     Unique<HeapObject> this_fun_constant = | 226     Unique<HeapObject> this_fun_constant = | 
| 226         Unique<HeapObject>::CreateUninitialized(function); | 227         Unique<HeapObject>::CreateUninitialized(function); | 
| 227     Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); | 228     Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); | 
| 228 | 229 | 
| 229     Handle<Context> context(function->context(), CcTest::i_isolate()); | 230     Handle<Context> context(function->context(), CcTest::i_isolate()); | 
| 230     Unique<HeapObject> context_constant = | 231     Unique<HeapObject> context_constant = | 
| 231         Unique<HeapObject>::CreateUninitialized(context); | 232         Unique<HeapObject>::CreateUninitialized(context); | 
| 232     Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 233     Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 
| 233 | 234 | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283   Handle<Object> result; | 284   Handle<Object> result; | 
| 284   bool has_pending_exception = | 285   bool has_pending_exception = | 
| 285       !Execution::Call(isolate, t.function, | 286       !Execution::Call(isolate, t.function, | 
| 286                        isolate->factory()->undefined_value(), 0, NULL, | 287                        isolate->factory()->undefined_value(), 0, NULL, | 
| 287                        false).ToHandle(&result); | 288                        false).ToHandle(&result); | 
| 288   CHECK(!has_pending_exception); | 289   CHECK(!has_pending_exception); | 
| 289   CHECK(result->SameValue(Smi::FromInt(42))); | 290   CHECK(result->SameValue(Smi::FromInt(42))); | 
| 290 } | 291 } | 
| 291 | 292 | 
| 292 #endif | 293 #endif | 
| OLD | NEW | 
|---|