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 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 class DeoptCodegenTester { | 42 class DeoptCodegenTester { |
43 public: | 43 public: |
44 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) | 44 explicit DeoptCodegenTester(HandleAndZoneScope* scope, const char* src) |
45 : scope_(scope), | 45 : scope_(scope), |
46 function(NewFunction(src)), | 46 function(NewFunction(src)), |
47 parse_info(scope->main_zone(), function), | 47 parse_info(scope->main_zone(), function), |
48 info(&parse_info), | 48 info(&parse_info), |
49 bailout_id(-1) { | 49 bailout_id(-1), |
| 50 tagged_type(1, kMachAnyTagged, zone()), |
| 51 empty_types(zone()) { |
50 CHECK(Parser::ParseStatic(&parse_info)); | 52 CHECK(Parser::ParseStatic(&parse_info)); |
51 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 53 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
52 CHECK(Compiler::Analyze(&parse_info)); | 54 CHECK(Compiler::Analyze(&parse_info)); |
53 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 55 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
54 | 56 |
55 DCHECK(info.shared_info()->has_deoptimization_support()); | 57 DCHECK(info.shared_info()->has_deoptimization_support()); |
56 | 58 |
57 graph = new (scope_->main_zone()) Graph(scope_->main_zone()); | 59 graph = new (scope_->main_zone()) Graph(scope_->main_zone()); |
58 } | 60 } |
59 | 61 |
(...skipping 16 matching lines...) Expand all Loading... |
76 Isolate* isolate() { return scope_->main_isolate(); } | 78 Isolate* isolate() { return scope_->main_isolate(); } |
77 | 79 |
78 HandleAndZoneScope* scope_; | 80 HandleAndZoneScope* scope_; |
79 Handle<JSFunction> function; | 81 Handle<JSFunction> function; |
80 ParseInfo parse_info; | 82 ParseInfo parse_info; |
81 CompilationInfo info; | 83 CompilationInfo info; |
82 BailoutId bailout_id; | 84 BailoutId bailout_id; |
83 Handle<Code> result_code; | 85 Handle<Code> result_code; |
84 TestInstrSeq* code; | 86 TestInstrSeq* code; |
85 Graph* graph; | 87 Graph* graph; |
| 88 ZoneVector<MachineType> tagged_type; |
| 89 ZoneVector<MachineType> empty_types; |
86 }; | 90 }; |
87 | 91 |
88 | 92 |
89 class TrivialDeoptCodegenTester : public DeoptCodegenTester { | 93 class TrivialDeoptCodegenTester : public DeoptCodegenTester { |
90 public: | 94 public: |
91 explicit TrivialDeoptCodegenTester(HandleAndZoneScope* scope) | 95 explicit TrivialDeoptCodegenTester(HandleAndZoneScope* scope) |
92 : DeoptCodegenTester(scope, | 96 : DeoptCodegenTester(scope, |
93 "function foo() { deopt(); return 42; }; foo") {} | 97 "function foo() { deopt(); return 42; }; foo") {} |
94 | 98 |
95 void GenerateCode() { | 99 void GenerateCode() { |
(...skipping 17 matching lines...) Expand all Loading... |
113 Unique<JSFunction>::CreateUninitialized(deopt_function); | 117 Unique<JSFunction>::CreateUninitialized(deopt_function); |
114 Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); | 118 Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); |
115 | 119 |
116 Handle<Context> caller_context(function->context(), CcTest::i_isolate()); | 120 Handle<Context> caller_context(function->context(), CcTest::i_isolate()); |
117 Unique<Context> caller_context_constant = | 121 Unique<Context> caller_context_constant = |
118 Unique<Context>::CreateUninitialized(caller_context); | 122 Unique<Context>::CreateUninitialized(caller_context); |
119 Node* caller_context_node = | 123 Node* caller_context_node = |
120 m.NewNode(common.HeapConstant(caller_context_constant)); | 124 m.NewNode(common.HeapConstant(caller_context_constant)); |
121 | 125 |
122 bailout_id = GetCallBailoutId(); | 126 bailout_id = GetCallBailoutId(); |
123 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); | 127 Node* parameters = |
124 Node* locals = m.NewNode(common.StateValues(0)); | 128 m.NewNode(common.TypedStateValues(&tagged_type), m.UndefinedConstant()); |
125 Node* stack = m.NewNode(common.StateValues(0)); | 129 Node* locals = m.NewNode(common.TypedStateValues(&empty_types)); |
| 130 Node* stack = m.NewNode(common.TypedStateValues(&empty_types)); |
126 | 131 |
127 Node* state_node = m.NewNode( | 132 Node* state_node = m.NewNode( |
128 common.FrameState(JS_FRAME, bailout_id, | 133 common.FrameState(JS_FRAME, bailout_id, |
129 OutputFrameStateCombine::Ignore()), | 134 OutputFrameStateCombine::Ignore()), |
130 parameters, locals, stack, caller_context_node, m.UndefinedConstant()); | 135 parameters, locals, stack, caller_context_node, m.UndefinedConstant()); |
131 | 136 |
132 Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); | 137 Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); |
133 Unique<Context> context_constant = | 138 Unique<Context> context_constant = |
134 Unique<Context>::CreateUninitialized(context); | 139 Unique<Context>::CreateUninitialized(context); |
135 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 140 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 Unique<HeapObject> this_fun_constant = | 233 Unique<HeapObject> this_fun_constant = |
229 Unique<HeapObject>::CreateUninitialized(function); | 234 Unique<HeapObject>::CreateUninitialized(function); |
230 Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); | 235 Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); |
231 | 236 |
232 Handle<Context> context(function->context(), CcTest::i_isolate()); | 237 Handle<Context> context(function->context(), CcTest::i_isolate()); |
233 Unique<HeapObject> context_constant = | 238 Unique<HeapObject> context_constant = |
234 Unique<HeapObject>::CreateUninitialized(context); | 239 Unique<HeapObject>::CreateUninitialized(context); |
235 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 240 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); |
236 | 241 |
237 bailout_id = GetCallBailoutId(); | 242 bailout_id = GetCallBailoutId(); |
238 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); | 243 Node* parameters = |
239 Node* locals = m.NewNode(common.StateValues(0)); | 244 m.NewNode(common.TypedStateValues(&tagged_type), m.UndefinedConstant()); |
240 Node* stack = m.NewNode(common.StateValues(0)); | 245 Node* locals = m.NewNode(common.TypedStateValues(&empty_types)); |
| 246 Node* stack = m.NewNode(common.TypedStateValues(&empty_types)); |
241 | 247 |
242 Node* state_node = m.NewNode( | 248 Node* state_node = m.NewNode( |
243 common.FrameState(JS_FRAME, bailout_id, | 249 common.FrameState(JS_FRAME, bailout_id, |
244 OutputFrameStateCombine::Ignore()), | 250 OutputFrameStateCombine::Ignore()), |
245 parameters, locals, stack, context_node, m.UndefinedConstant()); | 251 parameters, locals, stack, context_node, m.UndefinedConstant()); |
246 | 252 |
247 m.CallRuntime1(Runtime::kDeoptimizeFunction, this_fun_node, context_node, | 253 m.CallRuntime1(Runtime::kDeoptimizeFunction, this_fun_node, context_node, |
248 state_node); | 254 state_node); |
249 | 255 |
250 m.Return(m.UndefinedConstant()); | 256 m.Return(m.UndefinedConstant()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Handle<Object> result; | 292 Handle<Object> result; |
287 bool has_pending_exception = | 293 bool has_pending_exception = |
288 !Execution::Call(isolate, t.function, | 294 !Execution::Call(isolate, t.function, |
289 isolate->factory()->undefined_value(), 0, NULL, | 295 isolate->factory()->undefined_value(), 0, NULL, |
290 false).ToHandle(&result); | 296 false).ToHandle(&result); |
291 CHECK(!has_pending_exception); | 297 CHECK(!has_pending_exception); |
292 CHECK(result->SameValue(Smi::FromInt(42))); | 298 CHECK(result->SameValue(Smi::FromInt(42))); |
293 } | 299 } |
294 | 300 |
295 #endif | 301 #endif |
OLD | NEW |