OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/code-events.h" |
7 | 7 #include "src/code-stub-assembler.h" |
8 #include "src/api-arguments.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/api-natives.h" | 9 #include "src/interface-descriptors.h" |
10 #include "src/code-factory.h" | 10 #include "src/isolate.h" |
11 #include "src/ic/handler-compiler.h" | 11 #include "src/macro-assembler.h" |
12 #include "src/ic/ic.h" | 12 #include "src/objects.h" |
13 #include "src/vm-state-inl.h" | |
14 | 13 |
15 namespace v8 { | 14 namespace v8 { |
16 namespace internal { | 15 namespace internal { |
17 | 16 |
18 // Forward declarations for C++ builtins. | 17 // Forward declarations for C++ builtins. |
19 #define FORWARD_DECLARE(Name) \ | 18 #define FORWARD_DECLARE(Name) \ |
20 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); | 19 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); |
21 BUILTIN_LIST_C(FORWARD_DECLARE) | 20 BUILTIN_LIST_C(FORWARD_DECLARE) |
22 #undef FORWARD_DECLARE | |
23 | |
24 // ----------------------------------------------------------------------------- | |
25 // ES6 section 19.2 Function Objects | |
26 | |
27 // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] ( V ) | |
28 void Builtins::Generate_FunctionPrototypeHasInstance( | |
29 CodeStubAssembler* assembler) { | |
30 using compiler::Node; | |
31 | |
32 Node* f = assembler->Parameter(0); | |
33 Node* v = assembler->Parameter(1); | |
34 Node* context = assembler->Parameter(4); | |
35 Node* result = assembler->OrdinaryHasInstance(context, f, v); | |
36 assembler->Return(result); | |
37 } | |
38 | |
39 // ----------------------------------------------------------------------------- | |
40 // ES6 section 25.3 Generator Objects | |
41 | |
42 namespace { | |
43 | |
44 void Generate_GeneratorPrototypeResume( | |
45 CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode, | |
46 char const* const method_name) { | |
47 typedef CodeStubAssembler::Label Label; | |
48 typedef compiler::Node Node; | |
49 | |
50 Node* receiver = assembler->Parameter(0); | |
51 Node* value = assembler->Parameter(1); | |
52 Node* context = assembler->Parameter(4); | |
53 Node* closed = | |
54 assembler->SmiConstant(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); | |
55 | |
56 // Check if the {receiver} is actually a JSGeneratorObject. | |
57 Label if_receiverisincompatible(assembler, Label::kDeferred); | |
58 assembler->GotoIf(assembler->WordIsSmi(receiver), &if_receiverisincompatible); | |
59 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); | |
60 assembler->GotoUnless(assembler->Word32Equal( | |
61 receiver_instance_type, | |
62 assembler->Int32Constant(JS_GENERATOR_OBJECT_TYPE)), | |
63 &if_receiverisincompatible); | |
64 | |
65 // Check if the {receiver} is running or already closed. | |
66 Node* receiver_continuation = assembler->LoadObjectField( | |
67 receiver, JSGeneratorObject::kContinuationOffset); | |
68 Label if_receiverisclosed(assembler, Label::kDeferred), | |
69 if_receiverisrunning(assembler, Label::kDeferred); | |
70 assembler->GotoIf(assembler->SmiEqual(receiver_continuation, closed), | |
71 &if_receiverisclosed); | |
72 DCHECK_LT(JSGeneratorObject::kGeneratorExecuting, | |
73 JSGeneratorObject::kGeneratorClosed); | |
74 assembler->GotoIf(assembler->SmiLessThan(receiver_continuation, closed), | |
75 &if_receiverisrunning); | |
76 | |
77 // Resume the {receiver} using our trampoline. | |
78 Node* result = assembler->CallStub( | |
79 CodeFactory::ResumeGenerator(assembler->isolate()), context, value, | |
80 receiver, assembler->SmiConstant(Smi::FromInt(resume_mode))); | |
81 assembler->Return(result); | |
82 | |
83 assembler->Bind(&if_receiverisincompatible); | |
84 { | |
85 // The {receiver} is not a valid JSGeneratorObject. | |
86 Node* result = assembler->CallRuntime( | |
87 Runtime::kThrowIncompatibleMethodReceiver, context, | |
88 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( | |
89 method_name, TENURED)), | |
90 receiver); | |
91 assembler->Return(result); // Never reached. | |
92 } | |
93 | |
94 assembler->Bind(&if_receiverisclosed); | |
95 { | |
96 // The {receiver} is closed already. | |
97 Node* result = nullptr; | |
98 switch (resume_mode) { | |
99 case JSGeneratorObject::kNext: | |
100 result = assembler->CallRuntime(Runtime::kCreateIterResultObject, | |
101 context, assembler->UndefinedConstant(), | |
102 assembler->BooleanConstant(true)); | |
103 break; | |
104 case JSGeneratorObject::kReturn: | |
105 result = | |
106 assembler->CallRuntime(Runtime::kCreateIterResultObject, context, | |
107 value, assembler->BooleanConstant(true)); | |
108 break; | |
109 case JSGeneratorObject::kThrow: | |
110 result = assembler->CallRuntime(Runtime::kThrow, context, value); | |
111 break; | |
112 } | |
113 assembler->Return(result); | |
114 } | |
115 | |
116 assembler->Bind(&if_receiverisrunning); | |
117 { | |
118 Node* result = | |
119 assembler->CallRuntime(Runtime::kThrowGeneratorRunning, context); | |
120 assembler->Return(result); // Never reached. | |
121 } | |
122 } | |
123 | |
124 } // namespace | |
125 | |
126 // ES6 section 25.3.1.2 Generator.prototype.next ( value ) | |
127 void Builtins::Generate_GeneratorPrototypeNext(CodeStubAssembler* assembler) { | |
128 Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kNext, | |
129 "[Generator].prototype.next"); | |
130 } | |
131 | |
132 // ES6 section 25.3.1.3 Generator.prototype.return ( value ) | |
133 void Builtins::Generate_GeneratorPrototypeReturn(CodeStubAssembler* assembler) { | |
134 Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kReturn, | |
135 "[Generator].prototype.return"); | |
136 } | |
137 | |
138 // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) | |
139 void Builtins::Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler) { | |
140 Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow, | |
141 "[Generator].prototype.throw"); | |
142 } | |
143 | |
144 // ----------------------------------------------------------------------------- | |
145 | |
146 // | |
147 | |
148 namespace { | |
149 | |
150 // Returns the holder JSObject if the function can legally be called with this | |
151 // receiver. Returns nullptr if the call is illegal. | |
152 // TODO(dcarney): CallOptimization duplicates this logic, merge. | |
153 JSObject* GetCompatibleReceiver(Isolate* isolate, FunctionTemplateInfo* info, | |
154 JSObject* receiver) { | |
155 Object* recv_type = info->signature(); | |
156 // No signature, return holder. | |
157 if (!recv_type->IsFunctionTemplateInfo()) return receiver; | |
158 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type); | |
159 | |
160 // Check the receiver. Fast path for receivers with no hidden prototypes. | |
161 if (signature->IsTemplateFor(receiver)) return receiver; | |
162 if (!receiver->map()->has_hidden_prototype()) return nullptr; | |
163 for (PrototypeIterator iter(isolate, receiver, kStartAtPrototype, | |
164 PrototypeIterator::END_AT_NON_HIDDEN); | |
165 !iter.IsAtEnd(); iter.Advance()) { | |
166 JSObject* current = iter.GetCurrent<JSObject>(); | |
167 if (signature->IsTemplateFor(current)) return current; | |
168 } | |
169 return nullptr; | |
170 } | |
171 | |
172 template <bool is_construct> | |
173 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( | |
174 Isolate* isolate, Handle<HeapObject> function, | |
175 Handle<HeapObject> new_target, Handle<FunctionTemplateInfo> fun_data, | |
176 Handle<Object> receiver, BuiltinArguments args) { | |
177 Handle<JSObject> js_receiver; | |
178 JSObject* raw_holder; | |
179 if (is_construct) { | |
180 DCHECK(args.receiver()->IsTheHole(isolate)); | |
181 if (fun_data->instance_template()->IsUndefined(isolate)) { | |
182 v8::Local<ObjectTemplate> templ = | |
183 ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate), | |
184 ToApiHandle<v8::FunctionTemplate>(fun_data)); | |
185 fun_data->set_instance_template(*Utils::OpenHandle(*templ)); | |
186 } | |
187 Handle<ObjectTemplateInfo> instance_template( | |
188 ObjectTemplateInfo::cast(fun_data->instance_template()), isolate); | |
189 ASSIGN_RETURN_ON_EXCEPTION( | |
190 isolate, js_receiver, | |
191 ApiNatives::InstantiateObject(instance_template, | |
192 Handle<JSReceiver>::cast(new_target)), | |
193 Object); | |
194 args[0] = *js_receiver; | |
195 DCHECK_EQ(*js_receiver, *args.receiver()); | |
196 | |
197 raw_holder = *js_receiver; | |
198 } else { | |
199 DCHECK(receiver->IsJSReceiver()); | |
200 | |
201 if (!receiver->IsJSObject()) { | |
202 // This function cannot be called with the given receiver. Abort! | |
203 THROW_NEW_ERROR( | |
204 isolate, NewTypeError(MessageTemplate::kIllegalInvocation), Object); | |
205 } | |
206 | |
207 js_receiver = Handle<JSObject>::cast(receiver); | |
208 | |
209 if (!fun_data->accept_any_receiver() && | |
210 js_receiver->IsAccessCheckNeeded() && | |
211 !isolate->MayAccess(handle(isolate->context()), js_receiver)) { | |
212 isolate->ReportFailedAccessCheck(js_receiver); | |
213 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | |
214 } | |
215 | |
216 raw_holder = GetCompatibleReceiver(isolate, *fun_data, *js_receiver); | |
217 | |
218 if (raw_holder == nullptr) { | |
219 // This function cannot be called with the given receiver. Abort! | |
220 THROW_NEW_ERROR( | |
221 isolate, NewTypeError(MessageTemplate::kIllegalInvocation), Object); | |
222 } | |
223 } | |
224 | |
225 Object* raw_call_data = fun_data->call_code(); | |
226 if (!raw_call_data->IsUndefined(isolate)) { | |
227 DCHECK(raw_call_data->IsCallHandlerInfo()); | |
228 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | |
229 Object* callback_obj = call_data->callback(); | |
230 v8::FunctionCallback callback = | |
231 v8::ToCData<v8::FunctionCallback>(callback_obj); | |
232 Object* data_obj = call_data->data(); | |
233 | |
234 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*js_receiver))); | |
235 | |
236 FunctionCallbackArguments custom(isolate, data_obj, *function, raw_holder, | |
237 *new_target, &args[0] - 1, | |
238 args.length() - 1); | |
239 | |
240 Handle<Object> result = custom.Call(callback); | |
241 | |
242 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | |
243 if (result.is_null()) { | |
244 if (is_construct) return js_receiver; | |
245 return isolate->factory()->undefined_value(); | |
246 } | |
247 // Rebox the result. | |
248 result->VerifyApiCallResultType(); | |
249 if (!is_construct || result->IsJSObject()) return handle(*result, isolate); | |
250 } | |
251 | |
252 return js_receiver; | |
253 } | |
254 | |
255 } // namespace | |
256 | |
257 BUILTIN(HandleApiCall) { | |
258 HandleScope scope(isolate); | |
259 Handle<JSFunction> function = args.target<JSFunction>(); | |
260 Handle<Object> receiver = args.receiver(); | |
261 Handle<HeapObject> new_target = args.new_target(); | |
262 Handle<FunctionTemplateInfo> fun_data(function->shared()->get_api_func_data(), | |
263 isolate); | |
264 if (new_target->IsJSReceiver()) { | |
265 RETURN_RESULT_OR_FAILURE( | |
266 isolate, HandleApiCallHelper<true>(isolate, function, new_target, | |
267 fun_data, receiver, args)); | |
268 } else { | |
269 RETURN_RESULT_OR_FAILURE( | |
270 isolate, HandleApiCallHelper<false>(isolate, function, new_target, | |
271 fun_data, receiver, args)); | |
272 } | |
273 } | |
274 | |
275 Handle<Code> Builtins::CallFunction(ConvertReceiverMode mode, | |
276 TailCallMode tail_call_mode) { | |
277 switch (tail_call_mode) { | |
278 case TailCallMode::kDisallow: | |
279 switch (mode) { | |
280 case ConvertReceiverMode::kNullOrUndefined: | |
281 return CallFunction_ReceiverIsNullOrUndefined(); | |
282 case ConvertReceiverMode::kNotNullOrUndefined: | |
283 return CallFunction_ReceiverIsNotNullOrUndefined(); | |
284 case ConvertReceiverMode::kAny: | |
285 return CallFunction_ReceiverIsAny(); | |
286 } | |
287 break; | |
288 case TailCallMode::kAllow: | |
289 switch (mode) { | |
290 case ConvertReceiverMode::kNullOrUndefined: | |
291 return TailCallFunction_ReceiverIsNullOrUndefined(); | |
292 case ConvertReceiverMode::kNotNullOrUndefined: | |
293 return TailCallFunction_ReceiverIsNotNullOrUndefined(); | |
294 case ConvertReceiverMode::kAny: | |
295 return TailCallFunction_ReceiverIsAny(); | |
296 } | |
297 break; | |
298 } | |
299 UNREACHABLE(); | |
300 return Handle<Code>::null(); | |
301 } | |
302 | |
303 Handle<Code> Builtins::Call(ConvertReceiverMode mode, | |
304 TailCallMode tail_call_mode) { | |
305 switch (tail_call_mode) { | |
306 case TailCallMode::kDisallow: | |
307 switch (mode) { | |
308 case ConvertReceiverMode::kNullOrUndefined: | |
309 return Call_ReceiverIsNullOrUndefined(); | |
310 case ConvertReceiverMode::kNotNullOrUndefined: | |
311 return Call_ReceiverIsNotNullOrUndefined(); | |
312 case ConvertReceiverMode::kAny: | |
313 return Call_ReceiverIsAny(); | |
314 } | |
315 break; | |
316 case TailCallMode::kAllow: | |
317 switch (mode) { | |
318 case ConvertReceiverMode::kNullOrUndefined: | |
319 return TailCall_ReceiverIsNullOrUndefined(); | |
320 case ConvertReceiverMode::kNotNullOrUndefined: | |
321 return TailCall_ReceiverIsNotNullOrUndefined(); | |
322 case ConvertReceiverMode::kAny: | |
323 return TailCall_ReceiverIsAny(); | |
324 } | |
325 break; | |
326 } | |
327 UNREACHABLE(); | |
328 return Handle<Code>::null(); | |
329 } | |
330 | |
331 Handle<Code> Builtins::CallBoundFunction(TailCallMode tail_call_mode) { | |
332 switch (tail_call_mode) { | |
333 case TailCallMode::kDisallow: | |
334 return CallBoundFunction(); | |
335 case TailCallMode::kAllow: | |
336 return TailCallBoundFunction(); | |
337 } | |
338 UNREACHABLE(); | |
339 return Handle<Code>::null(); | |
340 } | |
341 | |
342 namespace { | |
343 | |
344 class RelocatableArguments : public BuiltinArguments, public Relocatable { | |
345 public: | |
346 RelocatableArguments(Isolate* isolate, int length, Object** arguments) | |
347 : BuiltinArguments(length, arguments), Relocatable(isolate) {} | |
348 | |
349 virtual inline void IterateInstance(ObjectVisitor* v) { | |
350 if (length() == 0) return; | |
351 v->VisitPointers(lowest_address(), highest_address() + 1); | |
352 } | |
353 | |
354 private: | |
355 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); | |
356 }; | |
357 | |
358 } // namespace | |
359 | |
360 MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate, | |
361 Handle<HeapObject> function, | |
362 Handle<Object> receiver, | |
363 int argc, | |
364 Handle<Object> args[]) { | |
365 DCHECK(function->IsFunctionTemplateInfo() || | |
366 (function->IsJSFunction() && | |
367 JSFunction::cast(*function)->shared()->IsApiFunction())); | |
368 | |
369 // Do proper receiver conversion for non-strict mode api functions. | |
370 if (!receiver->IsJSReceiver()) { | |
371 if (function->IsFunctionTemplateInfo() || | |
372 is_sloppy(JSFunction::cast(*function)->shared()->language_mode())) { | |
373 ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver, | |
374 Object::ConvertReceiver(isolate, receiver), | |
375 Object); | |
376 } | |
377 } | |
378 | |
379 Handle<FunctionTemplateInfo> fun_data = | |
380 function->IsFunctionTemplateInfo() | |
381 ? Handle<FunctionTemplateInfo>::cast(function) | |
382 : handle(JSFunction::cast(*function)->shared()->get_api_func_data(), | |
383 isolate); | |
384 Handle<HeapObject> new_target = isolate->factory()->undefined_value(); | |
385 // Construct BuiltinArguments object: | |
386 // new target, function, arguments reversed, receiver. | |
387 const int kBufferSize = 32; | |
388 Object* small_argv[kBufferSize]; | |
389 Object** argv; | |
390 const int frame_argc = argc + BuiltinArguments::kNumExtraArgsWithReceiver; | |
391 if (frame_argc <= kBufferSize) { | |
392 argv = small_argv; | |
393 } else { | |
394 argv = new Object*[frame_argc]; | |
395 } | |
396 int cursor = frame_argc - 1; | |
397 argv[cursor--] = *receiver; | |
398 for (int i = 0; i < argc; ++i) { | |
399 argv[cursor--] = *args[i]; | |
400 } | |
401 DCHECK(cursor == BuiltinArguments::kArgcOffset); | |
402 argv[BuiltinArguments::kArgcOffset] = Smi::FromInt(frame_argc); | |
403 argv[BuiltinArguments::kTargetOffset] = *function; | |
404 argv[BuiltinArguments::kNewTargetOffset] = *new_target; | |
405 MaybeHandle<Object> result; | |
406 { | |
407 RelocatableArguments arguments(isolate, frame_argc, &argv[frame_argc - 1]); | |
408 result = HandleApiCallHelper<false>(isolate, function, new_target, fun_data, | |
409 receiver, arguments); | |
410 } | |
411 if (argv != small_argv) delete[] argv; | |
412 return result; | |
413 } | |
414 | |
415 // Helper function to handle calls to non-function objects created through the | |
416 // API. The object can be called as either a constructor (using new) or just as | |
417 // a function (without new). | |
418 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( | |
419 Isolate* isolate, bool is_construct_call, BuiltinArguments args) { | |
420 Handle<Object> receiver = args.receiver(); | |
421 | |
422 // Get the object called. | |
423 JSObject* obj = JSObject::cast(*receiver); | |
424 | |
425 // Set the new target. | |
426 HeapObject* new_target; | |
427 if (is_construct_call) { | |
428 // TODO(adamk): This should be passed through in args instead of | |
429 // being patched in here. We need to set a non-undefined value | |
430 // for v8::FunctionCallbackInfo::IsConstructCall() to get the | |
431 // right answer. | |
432 new_target = obj; | |
433 } else { | |
434 new_target = isolate->heap()->undefined_value(); | |
435 } | |
436 | |
437 // Get the invocation callback from the function descriptor that was | |
438 // used to create the called object. | |
439 DCHECK(obj->map()->is_callable()); | |
440 JSFunction* constructor = JSFunction::cast(obj->map()->GetConstructor()); | |
441 // TODO(ishell): turn this back to a DCHECK. | |
442 CHECK(constructor->shared()->IsApiFunction()); | |
443 Object* handler = | |
444 constructor->shared()->get_api_func_data()->instance_call_handler(); | |
445 DCHECK(!handler->IsUndefined(isolate)); | |
446 // TODO(ishell): remove this debugging code. | |
447 CHECK(handler->IsCallHandlerInfo()); | |
448 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); | |
449 Object* callback_obj = call_data->callback(); | |
450 v8::FunctionCallback callback = | |
451 v8::ToCData<v8::FunctionCallback>(callback_obj); | |
452 | |
453 // Get the data for the call and perform the callback. | |
454 Object* result; | |
455 { | |
456 HandleScope scope(isolate); | |
457 LOG(isolate, ApiObjectAccess("call non-function", obj)); | |
458 | |
459 FunctionCallbackArguments custom(isolate, call_data->data(), constructor, | |
460 obj, new_target, &args[0] - 1, | |
461 args.length() - 1); | |
462 Handle<Object> result_handle = custom.Call(callback); | |
463 if (result_handle.is_null()) { | |
464 result = isolate->heap()->undefined_value(); | |
465 } else { | |
466 result = *result_handle; | |
467 } | |
468 } | |
469 // Check for exceptions and return result. | |
470 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | |
471 return result; | |
472 } | |
473 | |
474 // Handle calls to non-function objects created through the API. This delegate | |
475 // function is used when the call is a normal function call. | |
476 BUILTIN(HandleApiCallAsFunction) { | |
477 return HandleApiCallAsFunctionOrConstructor(isolate, false, args); | |
478 } | |
479 | |
480 // Handle calls to non-function objects created through the API. This delegate | |
481 // function is used when the call is a construct call. | |
482 BUILTIN(HandleApiCallAsConstructor) { | |
483 return HandleApiCallAsFunctionOrConstructor(isolate, true, args); | |
484 } | |
485 | 21 |
486 Builtins::Builtins() : initialized_(false) { | 22 Builtins::Builtins() : initialized_(false) { |
487 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); | 23 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); |
488 } | 24 } |
489 | 25 |
490 Builtins::~Builtins() {} | 26 Builtins::~Builtins() {} |
491 | 27 |
492 namespace { | 28 namespace { |
493 void PostBuildProfileAndTracing(Isolate* isolate, Code* code, | 29 void PostBuildProfileAndTracing(Isolate* isolate, Code* code, |
494 const char* name) { | 30 const char* name) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 return #Name; | 191 return #Name; |
656 BUILTIN_LIST_ALL(CASE) | 192 BUILTIN_LIST_ALL(CASE) |
657 #undef CASE | 193 #undef CASE |
658 default: | 194 default: |
659 UNREACHABLE(); | 195 UNREACHABLE(); |
660 break; | 196 break; |
661 } | 197 } |
662 return ""; | 198 return ""; |
663 } | 199 } |
664 | 200 |
665 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) { | |
666 masm->TailCallRuntime(Runtime::kInterrupt); | |
667 } | |
668 | |
669 void Builtins::Generate_StackCheck(MacroAssembler* masm) { | |
670 masm->TailCallRuntime(Runtime::kStackGuard); | |
671 } | |
672 | |
673 void Builtins::Generate_CallFunction_ReceiverIsNullOrUndefined( | |
674 MacroAssembler* masm) { | |
675 Generate_CallFunction(masm, ConvertReceiverMode::kNullOrUndefined, | |
676 TailCallMode::kDisallow); | |
677 } | |
678 | |
679 void Builtins::Generate_CallFunction_ReceiverIsNotNullOrUndefined( | |
680 MacroAssembler* masm) { | |
681 Generate_CallFunction(masm, ConvertReceiverMode::kNotNullOrUndefined, | |
682 TailCallMode::kDisallow); | |
683 } | |
684 | |
685 void Builtins::Generate_CallFunction_ReceiverIsAny(MacroAssembler* masm) { | |
686 Generate_CallFunction(masm, ConvertReceiverMode::kAny, | |
687 TailCallMode::kDisallow); | |
688 } | |
689 | |
690 void Builtins::Generate_TailCallFunction_ReceiverIsNullOrUndefined( | |
691 MacroAssembler* masm) { | |
692 Generate_CallFunction(masm, ConvertReceiverMode::kNullOrUndefined, | |
693 TailCallMode::kAllow); | |
694 } | |
695 | |
696 void Builtins::Generate_TailCallFunction_ReceiverIsNotNullOrUndefined( | |
697 MacroAssembler* masm) { | |
698 Generate_CallFunction(masm, ConvertReceiverMode::kNotNullOrUndefined, | |
699 TailCallMode::kAllow); | |
700 } | |
701 | |
702 void Builtins::Generate_TailCallFunction_ReceiverIsAny(MacroAssembler* masm) { | |
703 Generate_CallFunction(masm, ConvertReceiverMode::kAny, TailCallMode::kAllow); | |
704 } | |
705 | |
706 void Builtins::Generate_CallBoundFunction(MacroAssembler* masm) { | |
707 Generate_CallBoundFunctionImpl(masm, TailCallMode::kDisallow); | |
708 } | |
709 | |
710 void Builtins::Generate_TailCallBoundFunction(MacroAssembler* masm) { | |
711 Generate_CallBoundFunctionImpl(masm, TailCallMode::kAllow); | |
712 } | |
713 | |
714 void Builtins::Generate_Call_ReceiverIsNullOrUndefined(MacroAssembler* masm) { | |
715 Generate_Call(masm, ConvertReceiverMode::kNullOrUndefined, | |
716 TailCallMode::kDisallow); | |
717 } | |
718 | |
719 void Builtins::Generate_Call_ReceiverIsNotNullOrUndefined( | |
720 MacroAssembler* masm) { | |
721 Generate_Call(masm, ConvertReceiverMode::kNotNullOrUndefined, | |
722 TailCallMode::kDisallow); | |
723 } | |
724 | |
725 void Builtins::Generate_Call_ReceiverIsAny(MacroAssembler* masm) { | |
726 Generate_Call(masm, ConvertReceiverMode::kAny, TailCallMode::kDisallow); | |
727 } | |
728 | |
729 void Builtins::Generate_TailCall_ReceiverIsNullOrUndefined( | |
730 MacroAssembler* masm) { | |
731 Generate_Call(masm, ConvertReceiverMode::kNullOrUndefined, | |
732 TailCallMode::kAllow); | |
733 } | |
734 | |
735 void Builtins::Generate_TailCall_ReceiverIsNotNullOrUndefined( | |
736 MacroAssembler* masm) { | |
737 Generate_Call(masm, ConvertReceiverMode::kNotNullOrUndefined, | |
738 TailCallMode::kAllow); | |
739 } | |
740 | |
741 void Builtins::Generate_TailCall_ReceiverIsAny(MacroAssembler* masm) { | |
742 Generate_Call(masm, ConvertReceiverMode::kAny, TailCallMode::kAllow); | |
743 } | |
744 | |
745 | |
746 #define DEFINE_BUILTIN_ACCESSOR(Name, ...) \ | 201 #define DEFINE_BUILTIN_ACCESSOR(Name, ...) \ |
747 Handle<Code> Builtins::Name() { \ | 202 Handle<Code> Builtins::Name() { \ |
748 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##Name)); \ | 203 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##Name)); \ |
749 return Handle<Code>(code_address); \ | 204 return Handle<Code>(code_address); \ |
750 } | 205 } |
751 BUILTIN_LIST_ALL(DEFINE_BUILTIN_ACCESSOR) | 206 BUILTIN_LIST_ALL(DEFINE_BUILTIN_ACCESSOR) |
752 #undef DEFINE_BUILTIN_ACCESSOR | 207 #undef DEFINE_BUILTIN_ACCESSOR |
753 | 208 |
754 } // namespace internal | 209 } // namespace internal |
755 } // namespace v8 | 210 } // namespace v8 |
OLD | NEW |