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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Manually construct a schedule for the function below: | 122 // Manually construct a schedule for the function below: |
123 // function foo() { | 123 // function foo() { |
124 // deopt(); | 124 // deopt(); |
125 // } | 125 // } |
126 | 126 |
127 CSignature1<Object*, Object*> sig; | 127 CSignature1<Object*, Object*> sig; |
128 RawMachineAssembler m(graph, &sig); | 128 RawMachineAssembler m(graph, &sig); |
129 | 129 |
130 Handle<JSFunction> deopt_function = | 130 Handle<JSFunction> deopt_function = |
131 NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); | 131 NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); |
132 Unique<Object> deopt_fun_constant = | 132 Unique<JSFunction> deopt_fun_constant = |
133 Unique<Object>::CreateUninitialized(deopt_function); | 133 Unique<JSFunction>::CreateUninitialized(deopt_function); |
134 Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); | 134 Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); |
135 | 135 |
136 Handle<Context> caller_context(function->context(), CcTest::i_isolate()); | 136 Handle<Context> caller_context(function->context(), CcTest::i_isolate()); |
137 Unique<Object> caller_context_constant = | 137 Unique<Context> caller_context_constant = |
138 Unique<Object>::CreateUninitialized(caller_context); | 138 Unique<Context>::CreateUninitialized(caller_context); |
139 Node* caller_context_node = | 139 Node* caller_context_node = |
140 m.NewNode(common.HeapConstant(caller_context_constant)); | 140 m.NewNode(common.HeapConstant(caller_context_constant)); |
141 | 141 |
142 bailout_id = GetCallBailoutId(); | 142 bailout_id = GetCallBailoutId(); |
143 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); | 143 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); |
144 Node* locals = m.NewNode(common.StateValues(0)); | 144 Node* locals = m.NewNode(common.StateValues(0)); |
145 Node* stack = m.NewNode(common.StateValues(0)); | 145 Node* stack = m.NewNode(common.StateValues(0)); |
146 | 146 |
147 Node* state_node = m.NewNode( | 147 Node* state_node = m.NewNode( |
148 common.FrameState(JS_FRAME, bailout_id, | 148 common.FrameState(JS_FRAME, bailout_id, |
149 OutputFrameStateCombine::Ignore()), | 149 OutputFrameStateCombine::Ignore()), |
150 parameters, locals, stack, caller_context_node, m.UndefinedConstant()); | 150 parameters, locals, stack, caller_context_node, m.UndefinedConstant()); |
151 | 151 |
152 Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); | 152 Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); |
153 Unique<Object> context_constant = | 153 Unique<Context> context_constant = |
154 Unique<Object>::CreateUninitialized(context); | 154 Unique<Context>::CreateUninitialized(context); |
155 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 155 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); |
156 | 156 |
157 m.CallJS0(deopt_fun_node, m.UndefinedConstant(), context_node, state_node); | 157 m.CallJS0(deopt_fun_node, m.UndefinedConstant(), context_node, state_node); |
158 | 158 |
159 m.Return(m.UndefinedConstant()); | 159 m.Return(m.UndefinedConstant()); |
160 | 160 |
161 // Schedule the graph: | 161 // Schedule the graph: |
162 Schedule* schedule = m.Export(); | 162 Schedule* schedule = m.Export(); |
163 | 163 |
164 return schedule; | 164 return schedule; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 CommonOperatorBuilder common(zone()); | 238 CommonOperatorBuilder common(zone()); |
239 | 239 |
240 // Manually construct a schedule for the function below: | 240 // Manually construct a schedule for the function below: |
241 // function foo() { | 241 // function foo() { |
242 // %DeoptimizeFunction(foo); | 242 // %DeoptimizeFunction(foo); |
243 // } | 243 // } |
244 | 244 |
245 CSignature1<Object*, Object*> sig; | 245 CSignature1<Object*, Object*> sig; |
246 RawMachineAssembler m(graph, &sig); | 246 RawMachineAssembler m(graph, &sig); |
247 | 247 |
248 Unique<Object> this_fun_constant = | 248 Unique<HeapObject> this_fun_constant = |
249 Unique<Object>::CreateUninitialized(function); | 249 Unique<HeapObject>::CreateUninitialized(function); |
250 Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); | 250 Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); |
251 | 251 |
252 Handle<Context> context(function->context(), CcTest::i_isolate()); | 252 Handle<Context> context(function->context(), CcTest::i_isolate()); |
253 Unique<Object> context_constant = | 253 Unique<HeapObject> context_constant = |
254 Unique<Object>::CreateUninitialized(context); | 254 Unique<HeapObject>::CreateUninitialized(context); |
255 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); | 255 Node* context_node = m.NewNode(common.HeapConstant(context_constant)); |
256 | 256 |
257 bailout_id = GetCallBailoutId(); | 257 bailout_id = GetCallBailoutId(); |
258 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); | 258 Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); |
259 Node* locals = m.NewNode(common.StateValues(0)); | 259 Node* locals = m.NewNode(common.StateValues(0)); |
260 Node* stack = m.NewNode(common.StateValues(0)); | 260 Node* stack = m.NewNode(common.StateValues(0)); |
261 | 261 |
262 Node* state_node = m.NewNode( | 262 Node* state_node = m.NewNode( |
263 common.FrameState(JS_FRAME, bailout_id, | 263 common.FrameState(JS_FRAME, bailout_id, |
264 OutputFrameStateCombine::Ignore()), | 264 OutputFrameStateCombine::Ignore()), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 Handle<Object> result; | 306 Handle<Object> result; |
307 bool has_pending_exception = | 307 bool has_pending_exception = |
308 !Execution::Call(isolate, t.function, | 308 !Execution::Call(isolate, t.function, |
309 isolate->factory()->undefined_value(), 0, NULL, | 309 isolate->factory()->undefined_value(), 0, NULL, |
310 false).ToHandle(&result); | 310 false).ToHandle(&result); |
311 CHECK(!has_pending_exception); | 311 CHECK(!has_pending_exception); |
312 CHECK(result->SameValue(Smi::FromInt(42))); | 312 CHECK(result->SameValue(Smi::FromInt(42))); |
313 } | 313 } |
314 | 314 |
315 #endif | 315 #endif |
OLD | NEW |