OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-utils.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/property-descriptor.h" | 9 #include "src/property-descriptor.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 // ----------------------------------------------------------------------------- | 14 // ----------------------------------------------------------------------------- |
15 // ES6 section 19.1 Object Objects | 15 // ES6 section 19.1 Object Objects |
16 | 16 |
17 void Builtins::Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler) { | 17 void Builtins::Generate_ObjectHasOwnProperty( |
| 18 compiler::CodeAssemblerState* state) { |
18 typedef compiler::Node Node; | 19 typedef compiler::Node Node; |
19 typedef CodeStubAssembler::Label Label; | 20 typedef CodeStubAssembler::Label Label; |
20 typedef CodeStubAssembler::Variable Variable; | 21 typedef CodeStubAssembler::Variable Variable; |
| 22 CodeStubAssembler assembler(state); |
21 | 23 |
22 Node* object = assembler->Parameter(0); | 24 Node* object = assembler.Parameter(0); |
23 Node* key = assembler->Parameter(1); | 25 Node* key = assembler.Parameter(1); |
24 Node* context = assembler->Parameter(4); | 26 Node* context = assembler.Parameter(4); |
25 | 27 |
26 Label call_runtime(assembler), return_true(assembler), | 28 Label call_runtime(&assembler), return_true(&assembler), |
27 return_false(assembler); | 29 return_false(&assembler); |
28 | 30 |
29 // Smi receivers do not have own properties. | 31 // Smi receivers do not have own properties. |
30 Label if_objectisnotsmi(assembler); | 32 Label if_objectisnotsmi(&assembler); |
31 assembler->Branch(assembler->TaggedIsSmi(object), &return_false, | 33 assembler.Branch(assembler.TaggedIsSmi(object), &return_false, |
32 &if_objectisnotsmi); | 34 &if_objectisnotsmi); |
33 assembler->Bind(&if_objectisnotsmi); | 35 assembler.Bind(&if_objectisnotsmi); |
34 | 36 |
35 Node* map = assembler->LoadMap(object); | 37 Node* map = assembler.LoadMap(object); |
36 Node* instance_type = assembler->LoadMapInstanceType(map); | 38 Node* instance_type = assembler.LoadMapInstanceType(map); |
37 | 39 |
38 Variable var_index(assembler, MachineType::PointerRepresentation()); | 40 Variable var_index(&assembler, MachineType::PointerRepresentation()); |
39 | 41 |
40 Label keyisindex(assembler), if_iskeyunique(assembler); | 42 Label keyisindex(&assembler), if_iskeyunique(&assembler); |
41 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique, | 43 assembler.TryToName(key, &keyisindex, &var_index, &if_iskeyunique, |
42 &call_runtime); | 44 &call_runtime); |
43 | 45 |
44 assembler->Bind(&if_iskeyunique); | 46 assembler.Bind(&if_iskeyunique); |
45 assembler->TryHasOwnProperty(object, map, instance_type, key, &return_true, | 47 assembler.TryHasOwnProperty(object, map, instance_type, key, &return_true, |
46 &return_false, &call_runtime); | 48 &return_false, &call_runtime); |
47 | 49 |
48 assembler->Bind(&keyisindex); | 50 assembler.Bind(&keyisindex); |
49 assembler->TryLookupElement(object, map, instance_type, var_index.value(), | 51 assembler.TryLookupElement(object, map, instance_type, var_index.value(), |
50 &return_true, &return_false, &call_runtime); | 52 &return_true, &return_false, &call_runtime); |
51 | 53 |
52 assembler->Bind(&return_true); | 54 assembler.Bind(&return_true); |
53 assembler->Return(assembler->BooleanConstant(true)); | 55 assembler.Return(assembler.BooleanConstant(true)); |
54 | 56 |
55 assembler->Bind(&return_false); | 57 assembler.Bind(&return_false); |
56 assembler->Return(assembler->BooleanConstant(false)); | 58 assembler.Return(assembler.BooleanConstant(false)); |
57 | 59 |
58 assembler->Bind(&call_runtime); | 60 assembler.Bind(&call_runtime); |
59 assembler->Return(assembler->CallRuntime(Runtime::kObjectHasOwnProperty, | 61 assembler.Return(assembler.CallRuntime(Runtime::kObjectHasOwnProperty, |
60 context, object, key)); | 62 context, object, key)); |
61 } | 63 } |
62 | 64 |
63 namespace { | 65 namespace { |
64 | 66 |
65 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, | 67 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, |
66 Handle<Object> next_source) { | 68 Handle<Object> next_source) { |
67 // Non-empty strings are the only non-JSReceivers that need to be handled | 69 // Non-empty strings are the only non-JSReceivers that need to be handled |
68 // explicitly by Object.assign. | 70 // explicitly by Object.assign. |
69 if (!next_source->IsJSReceiver()) { | 71 if (!next_source->IsJSReceiver()) { |
70 return Just(!next_source->IsString() || | 72 return Just(!next_source->IsString() || |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 268 |
267 assembler->GotoIf( | 269 assembler->GotoIf( |
268 assembler->Word32Equal(instance_type, | 270 assembler->Word32Equal(instance_type, |
269 assembler->Int32Constant(HEAP_NUMBER_TYPE)), | 271 assembler->Int32Constant(HEAP_NUMBER_TYPE)), |
270 return_number); | 272 return_number); |
271 } | 273 } |
272 | 274 |
273 } // namespace | 275 } // namespace |
274 | 276 |
275 // ES6 section 19.1.3.6 Object.prototype.toString | 277 // ES6 section 19.1.3.6 Object.prototype.toString |
276 void Builtins::Generate_ObjectProtoToString(CodeStubAssembler* assembler) { | 278 void Builtins::Generate_ObjectProtoToString( |
| 279 compiler::CodeAssemblerState* state) { |
277 typedef compiler::Node Node; | 280 typedef compiler::Node Node; |
278 typedef CodeStubAssembler::Label Label; | 281 typedef CodeStubAssembler::Label Label; |
279 typedef CodeStubAssembler::Variable Variable; | 282 typedef CodeStubAssembler::Variable Variable; |
| 283 CodeStubAssembler assembler(state); |
280 | 284 |
281 Label return_undefined(assembler, Label::kDeferred), | 285 Label return_undefined(&assembler, Label::kDeferred), |
282 return_null(assembler, Label::kDeferred), | 286 return_null(&assembler, Label::kDeferred), |
283 return_arguments(assembler, Label::kDeferred), return_array(assembler), | 287 return_arguments(&assembler, Label::kDeferred), return_array(&assembler), |
284 return_api(assembler, Label::kDeferred), return_object(assembler), | 288 return_api(&assembler, Label::kDeferred), return_object(&assembler), |
285 return_regexp(assembler), return_function(assembler), | 289 return_regexp(&assembler), return_function(&assembler), |
286 return_error(assembler), return_date(assembler), return_string(assembler), | 290 return_error(&assembler), return_date(&assembler), |
287 return_boolean(assembler), return_jsvalue(assembler), | 291 return_string(&assembler), return_boolean(&assembler), |
288 return_jsproxy(assembler, Label::kDeferred), return_number(assembler); | 292 return_jsvalue(&assembler), return_jsproxy(&assembler, Label::kDeferred), |
| 293 return_number(&assembler); |
289 | 294 |
290 Label if_isproxy(assembler, Label::kDeferred); | 295 Label if_isproxy(&assembler, Label::kDeferred); |
291 | 296 |
292 Label checkstringtag(assembler); | 297 Label checkstringtag(&assembler); |
293 Label if_tostringtag(assembler), if_notostringtag(assembler); | 298 Label if_tostringtag(&assembler), if_notostringtag(&assembler); |
294 | 299 |
295 Node* receiver = assembler->Parameter(0); | 300 Node* receiver = assembler.Parameter(0); |
296 Node* context = assembler->Parameter(3); | 301 Node* context = assembler.Parameter(3); |
297 | 302 |
298 assembler->GotoIf( | 303 assembler.GotoIf(assembler.WordEqual(receiver, assembler.UndefinedConstant()), |
299 assembler->WordEqual(receiver, assembler->UndefinedConstant()), | 304 &return_undefined); |
300 &return_undefined); | |
301 | 305 |
302 assembler->GotoIf(assembler->WordEqual(receiver, assembler->NullConstant()), | 306 assembler.GotoIf(assembler.WordEqual(receiver, assembler.NullConstant()), |
303 &return_null); | 307 &return_null); |
304 | 308 |
305 assembler->GotoIf(assembler->TaggedIsSmi(receiver), &return_number); | 309 assembler.GotoIf(assembler.TaggedIsSmi(receiver), &return_number); |
306 | 310 |
307 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); | 311 Node* receiver_instance_type = assembler.LoadInstanceType(receiver); |
308 ReturnIfPrimitive(assembler, receiver_instance_type, &return_string, | 312 ReturnIfPrimitive(&assembler, receiver_instance_type, &return_string, |
309 &return_boolean, &return_number); | 313 &return_boolean, &return_number); |
310 | 314 |
311 // for proxies, check IsArray before getting @@toStringTag | 315 // for proxies, check IsArray before getting @@toStringTag |
312 Variable var_proxy_is_array(assembler, MachineRepresentation::kTagged); | 316 Variable var_proxy_is_array(&assembler, MachineRepresentation::kTagged); |
313 var_proxy_is_array.Bind(assembler->BooleanConstant(false)); | 317 var_proxy_is_array.Bind(assembler.BooleanConstant(false)); |
314 | 318 |
315 assembler->Branch( | 319 assembler.Branch( |
316 assembler->Word32Equal(receiver_instance_type, | 320 assembler.Word32Equal(receiver_instance_type, |
317 assembler->Int32Constant(JS_PROXY_TYPE)), | 321 assembler.Int32Constant(JS_PROXY_TYPE)), |
318 &if_isproxy, &checkstringtag); | 322 &if_isproxy, &checkstringtag); |
319 | 323 |
320 assembler->Bind(&if_isproxy); | 324 assembler.Bind(&if_isproxy); |
321 { | 325 { |
322 // This can throw | 326 // This can throw |
323 var_proxy_is_array.Bind( | 327 var_proxy_is_array.Bind( |
324 assembler->CallRuntime(Runtime::kArrayIsArray, context, receiver)); | 328 assembler.CallRuntime(Runtime::kArrayIsArray, context, receiver)); |
325 assembler->Goto(&checkstringtag); | 329 assembler.Goto(&checkstringtag); |
326 } | 330 } |
327 | 331 |
328 assembler->Bind(&checkstringtag); | 332 assembler.Bind(&checkstringtag); |
329 { | 333 { |
330 Node* to_string_tag_symbol = assembler->HeapConstant( | 334 Node* to_string_tag_symbol = assembler.HeapConstant( |
331 assembler->isolate()->factory()->to_string_tag_symbol()); | 335 assembler.isolate()->factory()->to_string_tag_symbol()); |
332 | 336 |
333 GetPropertyStub stub(assembler->isolate()); | 337 GetPropertyStub stub(assembler.isolate()); |
334 Callable get_property = | 338 Callable get_property = |
335 Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); | 339 Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
336 Node* to_string_tag_value = assembler->CallStub( | 340 Node* to_string_tag_value = assembler.CallStub( |
337 get_property, context, receiver, to_string_tag_symbol); | 341 get_property, context, receiver, to_string_tag_symbol); |
338 | 342 |
339 IsString(assembler, to_string_tag_value, &if_tostringtag, | 343 IsString(&assembler, to_string_tag_value, &if_tostringtag, |
340 &if_notostringtag); | 344 &if_notostringtag); |
341 | 345 |
342 assembler->Bind(&if_tostringtag); | 346 assembler.Bind(&if_tostringtag); |
343 ReturnToStringFormat(assembler, context, to_string_tag_value); | 347 ReturnToStringFormat(&assembler, context, to_string_tag_value); |
344 } | 348 } |
345 assembler->Bind(&if_notostringtag); | 349 assembler.Bind(&if_notostringtag); |
346 { | 350 { |
347 size_t const kNumCases = 11; | 351 size_t const kNumCases = 11; |
348 Label* case_labels[kNumCases]; | 352 Label* case_labels[kNumCases]; |
349 int32_t case_values[kNumCases]; | 353 int32_t case_values[kNumCases]; |
350 case_labels[0] = &return_api; | 354 case_labels[0] = &return_api; |
351 case_values[0] = JS_API_OBJECT_TYPE; | 355 case_values[0] = JS_API_OBJECT_TYPE; |
352 case_labels[1] = &return_api; | 356 case_labels[1] = &return_api; |
353 case_values[1] = JS_SPECIAL_API_OBJECT_TYPE; | 357 case_values[1] = JS_SPECIAL_API_OBJECT_TYPE; |
354 case_labels[2] = &return_arguments; | 358 case_labels[2] = &return_arguments; |
355 case_values[2] = JS_ARGUMENTS_TYPE; | 359 case_values[2] = JS_ARGUMENTS_TYPE; |
356 case_labels[3] = &return_array; | 360 case_labels[3] = &return_array; |
357 case_values[3] = JS_ARRAY_TYPE; | 361 case_values[3] = JS_ARRAY_TYPE; |
358 case_labels[4] = &return_function; | 362 case_labels[4] = &return_function; |
359 case_values[4] = JS_BOUND_FUNCTION_TYPE; | 363 case_values[4] = JS_BOUND_FUNCTION_TYPE; |
360 case_labels[5] = &return_function; | 364 case_labels[5] = &return_function; |
361 case_values[5] = JS_FUNCTION_TYPE; | 365 case_values[5] = JS_FUNCTION_TYPE; |
362 case_labels[6] = &return_error; | 366 case_labels[6] = &return_error; |
363 case_values[6] = JS_ERROR_TYPE; | 367 case_values[6] = JS_ERROR_TYPE; |
364 case_labels[7] = &return_date; | 368 case_labels[7] = &return_date; |
365 case_values[7] = JS_DATE_TYPE; | 369 case_values[7] = JS_DATE_TYPE; |
366 case_labels[8] = &return_regexp; | 370 case_labels[8] = &return_regexp; |
367 case_values[8] = JS_REGEXP_TYPE; | 371 case_values[8] = JS_REGEXP_TYPE; |
368 case_labels[9] = &return_jsvalue; | 372 case_labels[9] = &return_jsvalue; |
369 case_values[9] = JS_VALUE_TYPE; | 373 case_values[9] = JS_VALUE_TYPE; |
370 case_labels[10] = &return_jsproxy; | 374 case_labels[10] = &return_jsproxy; |
371 case_values[10] = JS_PROXY_TYPE; | 375 case_values[10] = JS_PROXY_TYPE; |
372 | 376 |
373 assembler->Switch(receiver_instance_type, &return_object, case_values, | 377 assembler.Switch(receiver_instance_type, &return_object, case_values, |
374 case_labels, arraysize(case_values)); | 378 case_labels, arraysize(case_values)); |
375 | 379 |
376 assembler->Bind(&return_undefined); | 380 assembler.Bind(&return_undefined); |
377 assembler->Return(assembler->HeapConstant( | 381 assembler.Return(assembler.HeapConstant( |
378 assembler->isolate()->factory()->undefined_to_string())); | 382 assembler.isolate()->factory()->undefined_to_string())); |
379 | 383 |
380 assembler->Bind(&return_null); | 384 assembler.Bind(&return_null); |
381 assembler->Return(assembler->HeapConstant( | 385 assembler.Return(assembler.HeapConstant( |
382 assembler->isolate()->factory()->null_to_string())); | 386 assembler.isolate()->factory()->null_to_string())); |
383 | 387 |
384 assembler->Bind(&return_number); | 388 assembler.Bind(&return_number); |
385 assembler->Return(assembler->HeapConstant( | 389 assembler.Return(assembler.HeapConstant( |
386 assembler->isolate()->factory()->number_to_string())); | 390 assembler.isolate()->factory()->number_to_string())); |
387 | 391 |
388 assembler->Bind(&return_string); | 392 assembler.Bind(&return_string); |
389 assembler->Return(assembler->HeapConstant( | 393 assembler.Return(assembler.HeapConstant( |
390 assembler->isolate()->factory()->string_to_string())); | 394 assembler.isolate()->factory()->string_to_string())); |
391 | 395 |
392 assembler->Bind(&return_boolean); | 396 assembler.Bind(&return_boolean); |
393 assembler->Return(assembler->HeapConstant( | 397 assembler.Return(assembler.HeapConstant( |
394 assembler->isolate()->factory()->boolean_to_string())); | 398 assembler.isolate()->factory()->boolean_to_string())); |
395 | 399 |
396 assembler->Bind(&return_arguments); | 400 assembler.Bind(&return_arguments); |
397 assembler->Return(assembler->HeapConstant( | 401 assembler.Return(assembler.HeapConstant( |
398 assembler->isolate()->factory()->arguments_to_string())); | 402 assembler.isolate()->factory()->arguments_to_string())); |
399 | 403 |
400 assembler->Bind(&return_array); | 404 assembler.Bind(&return_array); |
401 assembler->Return(assembler->HeapConstant( | 405 assembler.Return(assembler.HeapConstant( |
402 assembler->isolate()->factory()->array_to_string())); | 406 assembler.isolate()->factory()->array_to_string())); |
403 | 407 |
404 assembler->Bind(&return_function); | 408 assembler.Bind(&return_function); |
405 assembler->Return(assembler->HeapConstant( | 409 assembler.Return(assembler.HeapConstant( |
406 assembler->isolate()->factory()->function_to_string())); | 410 assembler.isolate()->factory()->function_to_string())); |
407 | 411 |
408 assembler->Bind(&return_error); | 412 assembler.Bind(&return_error); |
409 assembler->Return(assembler->HeapConstant( | 413 assembler.Return(assembler.HeapConstant( |
410 assembler->isolate()->factory()->error_to_string())); | 414 assembler.isolate()->factory()->error_to_string())); |
411 | 415 |
412 assembler->Bind(&return_date); | 416 assembler.Bind(&return_date); |
413 assembler->Return(assembler->HeapConstant( | 417 assembler.Return(assembler.HeapConstant( |
414 assembler->isolate()->factory()->date_to_string())); | 418 assembler.isolate()->factory()->date_to_string())); |
415 | 419 |
416 assembler->Bind(&return_regexp); | 420 assembler.Bind(&return_regexp); |
417 assembler->Return(assembler->HeapConstant( | 421 assembler.Return(assembler.HeapConstant( |
418 assembler->isolate()->factory()->regexp_to_string())); | 422 assembler.isolate()->factory()->regexp_to_string())); |
419 | 423 |
420 assembler->Bind(&return_api); | 424 assembler.Bind(&return_api); |
421 { | 425 { |
422 Node* class_name = | 426 Node* class_name = |
423 assembler->CallRuntime(Runtime::kClassOf, context, receiver); | 427 assembler.CallRuntime(Runtime::kClassOf, context, receiver); |
424 ReturnToStringFormat(assembler, context, class_name); | 428 ReturnToStringFormat(&assembler, context, class_name); |
425 } | 429 } |
426 | 430 |
427 assembler->Bind(&return_jsvalue); | 431 assembler.Bind(&return_jsvalue); |
428 { | 432 { |
429 Node* value = assembler->LoadJSValueValue(receiver); | 433 Node* value = assembler.LoadJSValueValue(receiver); |
430 assembler->GotoIf(assembler->TaggedIsSmi(value), &return_number); | 434 assembler.GotoIf(assembler.TaggedIsSmi(value), &return_number); |
431 | 435 |
432 ReturnIfPrimitive(assembler, assembler->LoadInstanceType(value), | 436 ReturnIfPrimitive(&assembler, assembler.LoadInstanceType(value), |
433 &return_string, &return_boolean, &return_number); | 437 &return_string, &return_boolean, &return_number); |
434 assembler->Goto(&return_object); | 438 assembler.Goto(&return_object); |
435 } | 439 } |
436 | 440 |
437 assembler->Bind(&return_jsproxy); | 441 assembler.Bind(&return_jsproxy); |
438 { | 442 { |
439 assembler->GotoIf(assembler->WordEqual(var_proxy_is_array.value(), | 443 assembler.GotoIf(assembler.WordEqual(var_proxy_is_array.value(), |
440 assembler->BooleanConstant(true)), | 444 assembler.BooleanConstant(true)), |
441 &return_array); | 445 &return_array); |
442 | 446 |
443 Node* map = assembler->LoadMap(receiver); | 447 Node* map = assembler.LoadMap(receiver); |
444 | 448 |
445 // Return object if the proxy {receiver} is not callable. | 449 // Return object if the proxy {receiver} is not callable. |
446 assembler->Branch(assembler->IsCallableMap(map), &return_function, | 450 assembler.Branch(assembler.IsCallableMap(map), &return_function, |
447 &return_object); | 451 &return_object); |
448 } | 452 } |
449 | 453 |
450 // Default | 454 // Default |
451 assembler->Bind(&return_object); | 455 assembler.Bind(&return_object); |
452 assembler->Return(assembler->HeapConstant( | 456 assembler.Return(assembler.HeapConstant( |
453 assembler->isolate()->factory()->object_to_string())); | 457 assembler.isolate()->factory()->object_to_string())); |
454 } | 458 } |
455 } | 459 } |
456 | 460 |
457 void Builtins::Generate_ObjectCreate(CodeStubAssembler* a) { | 461 void Builtins::Generate_ObjectCreate(compiler::CodeAssemblerState* state) { |
458 typedef compiler::Node Node; | 462 typedef compiler::Node Node; |
459 typedef CodeStubAssembler::Label Label; | 463 typedef CodeStubAssembler::Label Label; |
460 typedef CodeStubAssembler::Variable Variable; | 464 typedef CodeStubAssembler::Variable Variable; |
| 465 CodeStubAssembler a(state); |
461 | 466 |
462 Node* prototype = a->Parameter(1); | 467 Node* prototype = a.Parameter(1); |
463 Node* properties = a->Parameter(2); | 468 Node* properties = a.Parameter(2); |
464 Node* context = a->Parameter(3 + 2); | 469 Node* context = a.Parameter(3 + 2); |
465 | 470 |
466 Label call_runtime(a, Label::kDeferred), prototype_valid(a), no_properties(a); | 471 Label call_runtime(&a, Label::kDeferred), prototype_valid(&a), |
| 472 no_properties(&a); |
467 { | 473 { |
468 a->Comment("Argument 1 check: prototype"); | 474 a.Comment("Argument 1 check: prototype"); |
469 a->GotoIf(a->WordEqual(prototype, a->NullConstant()), &prototype_valid); | 475 a.GotoIf(a.WordEqual(prototype, a.NullConstant()), &prototype_valid); |
470 a->BranchIfJSReceiver(prototype, &prototype_valid, &call_runtime); | 476 a.BranchIfJSReceiver(prototype, &prototype_valid, &call_runtime); |
471 } | 477 } |
472 | 478 |
473 a->Bind(&prototype_valid); | 479 a.Bind(&prototype_valid); |
474 { | 480 { |
475 a->Comment("Argument 2 check: properties"); | 481 a.Comment("Argument 2 check: properties"); |
476 // Check that we have a simple object | 482 // Check that we have a simple object |
477 a->GotoIf(a->TaggedIsSmi(properties), &call_runtime); | 483 a.GotoIf(a.TaggedIsSmi(properties), &call_runtime); |
478 // Undefined implies no properties. | 484 // Undefined implies no properties. |
479 a->GotoIf(a->WordEqual(properties, a->UndefinedConstant()), &no_properties); | 485 a.GotoIf(a.WordEqual(properties, a.UndefinedConstant()), &no_properties); |
480 Node* properties_map = a->LoadMap(properties); | 486 Node* properties_map = a.LoadMap(properties); |
481 a->GotoIf(a->IsSpecialReceiverMap(properties_map), &call_runtime); | 487 a.GotoIf(a.IsSpecialReceiverMap(properties_map), &call_runtime); |
482 // Stay on the fast path only if there are no elements. | 488 // Stay on the fast path only if there are no elements. |
483 a->GotoUnless(a->WordEqual(a->LoadElements(properties), | 489 a.GotoUnless(a.WordEqual(a.LoadElements(properties), |
484 a->LoadRoot(Heap::kEmptyFixedArrayRootIndex)), | 490 a.LoadRoot(Heap::kEmptyFixedArrayRootIndex)), |
485 &call_runtime); | 491 &call_runtime); |
486 // Handle dictionary objects or fast objects with properties in runtime. | 492 // Handle dictionary objects or fast objects with properties in runtime. |
487 Node* bit_field3 = a->LoadMapBitField3(properties_map); | 493 Node* bit_field3 = a.LoadMapBitField3(properties_map); |
488 a->GotoIf(a->IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime); | 494 a.GotoIf(a.IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime); |
489 a->Branch(a->IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3), | 495 a.Branch(a.IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3), |
490 &call_runtime, &no_properties); | 496 &call_runtime, &no_properties); |
491 } | 497 } |
492 | 498 |
493 // Create a new object with the given prototype. | 499 // Create a new object with the given prototype. |
494 a->Bind(&no_properties); | 500 a.Bind(&no_properties); |
495 { | 501 { |
496 Variable map(a, MachineRepresentation::kTagged); | 502 Variable map(&a, MachineRepresentation::kTagged); |
497 Variable properties(a, MachineRepresentation::kTagged); | 503 Variable properties(&a, MachineRepresentation::kTagged); |
498 Label non_null_proto(a), instantiate_map(a), good(a); | 504 Label non_null_proto(&a), instantiate_map(&a), good(&a); |
499 | 505 |
500 a->Branch(a->WordEqual(prototype, a->NullConstant()), &good, | 506 a.Branch(a.WordEqual(prototype, a.NullConstant()), &good, &non_null_proto); |
501 &non_null_proto); | |
502 | 507 |
503 a->Bind(&good); | 508 a.Bind(&good); |
504 { | 509 { |
505 map.Bind(a->LoadContextElement( | 510 map.Bind(a.LoadContextElement( |
506 context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP)); | 511 context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP)); |
507 properties.Bind( | 512 properties.Bind( |
508 a->AllocateNameDictionary(NameDictionary::kInitialCapacity)); | 513 a.AllocateNameDictionary(NameDictionary::kInitialCapacity)); |
509 a->Goto(&instantiate_map); | 514 a.Goto(&instantiate_map); |
510 } | 515 } |
511 | 516 |
512 a->Bind(&non_null_proto); | 517 a.Bind(&non_null_proto); |
513 { | 518 { |
514 properties.Bind(a->EmptyFixedArrayConstant()); | 519 properties.Bind(a.EmptyFixedArrayConstant()); |
515 Node* object_function = | 520 Node* object_function = |
516 a->LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); | 521 a.LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); |
517 Node* object_function_map = a->LoadObjectField( | 522 Node* object_function_map = a.LoadObjectField( |
518 object_function, JSFunction::kPrototypeOrInitialMapOffset); | 523 object_function, JSFunction::kPrototypeOrInitialMapOffset); |
519 map.Bind(object_function_map); | 524 map.Bind(object_function_map); |
520 a->GotoIf(a->WordEqual(prototype, a->LoadMapPrototype(map.value())), | 525 a.GotoIf(a.WordEqual(prototype, a.LoadMapPrototype(map.value())), |
521 &instantiate_map); | 526 &instantiate_map); |
522 // Try loading the prototype info. | 527 // Try loading the prototype info. |
523 Node* prototype_info = | 528 Node* prototype_info = |
524 a->LoadMapPrototypeInfo(a->LoadMap(prototype), &call_runtime); | 529 a.LoadMapPrototypeInfo(a.LoadMap(prototype), &call_runtime); |
525 a->Comment("Load ObjectCreateMap from PrototypeInfo"); | 530 a.Comment("Load ObjectCreateMap from PrototypeInfo"); |
526 Node* weak_cell = | 531 Node* weak_cell = |
527 a->LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); | 532 a.LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); |
528 a->GotoIf(a->WordEqual(weak_cell, a->UndefinedConstant()), &call_runtime); | 533 a.GotoIf(a.WordEqual(weak_cell, a.UndefinedConstant()), &call_runtime); |
529 map.Bind(a->LoadWeakCellValue(weak_cell, &call_runtime)); | 534 map.Bind(a.LoadWeakCellValue(weak_cell, &call_runtime)); |
530 a->Goto(&instantiate_map); | 535 a.Goto(&instantiate_map); |
531 } | 536 } |
532 | 537 |
533 a->Bind(&instantiate_map); | 538 a.Bind(&instantiate_map); |
534 { | 539 { |
535 Node* instance = | 540 Node* instance = |
536 a->AllocateJSObjectFromMap(map.value(), properties.value()); | 541 a.AllocateJSObjectFromMap(map.value(), properties.value()); |
537 a->Return(instance); | 542 a.Return(instance); |
538 } | 543 } |
539 } | 544 } |
540 | 545 |
541 a->Bind(&call_runtime); | 546 a.Bind(&call_runtime); |
542 { | 547 { |
543 a->Return( | 548 a.Return( |
544 a->CallRuntime(Runtime::kObjectCreate, context, prototype, properties)); | 549 a.CallRuntime(Runtime::kObjectCreate, context, prototype, properties)); |
545 } | 550 } |
546 } | 551 } |
547 | 552 |
548 // ES6 section 19.1.2.3 Object.defineProperties | 553 // ES6 section 19.1.2.3 Object.defineProperties |
549 BUILTIN(ObjectDefineProperties) { | 554 BUILTIN(ObjectDefineProperties) { |
550 HandleScope scope(isolate); | 555 HandleScope scope(isolate); |
551 DCHECK_EQ(3, args.length()); | 556 DCHECK_EQ(3, args.length()); |
552 Handle<Object> target = args.at<Object>(1); | 557 Handle<Object> target = args.at<Object>(1); |
553 Handle<Object> properties = args.at<Object>(2); | 558 Handle<Object> properties = args.at<Object>(2); |
554 | 559 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 HandleScope scope(isolate); | 1016 HandleScope scope(isolate); |
1012 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1017 Handle<Object> object = args.atOrUndefined(isolate, 1); |
1013 if (object->IsJSReceiver()) { | 1018 if (object->IsJSReceiver()) { |
1014 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object), | 1019 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object), |
1015 SEALED, Object::THROW_ON_ERROR), | 1020 SEALED, Object::THROW_ON_ERROR), |
1016 isolate->heap()->exception()); | 1021 isolate->heap()->exception()); |
1017 } | 1022 } |
1018 return *object; | 1023 return *object; |
1019 } | 1024 } |
1020 | 1025 |
1021 void Builtins::Generate_HasProperty(CodeStubAssembler* assembler) { | 1026 void Builtins::Generate_HasProperty(compiler::CodeAssemblerState* state) { |
1022 typedef HasPropertyDescriptor Descriptor; | 1027 typedef HasPropertyDescriptor Descriptor; |
1023 typedef compiler::Node Node; | 1028 typedef compiler::Node Node; |
| 1029 CodeStubAssembler assembler(state); |
1024 | 1030 |
1025 Node* key = assembler->Parameter(Descriptor::kKey); | 1031 Node* key = assembler.Parameter(Descriptor::kKey); |
1026 Node* object = assembler->Parameter(Descriptor::kObject); | 1032 Node* object = assembler.Parameter(Descriptor::kObject); |
1027 Node* context = assembler->Parameter(Descriptor::kContext); | 1033 Node* context = assembler.Parameter(Descriptor::kContext); |
1028 | 1034 |
1029 assembler->Return( | 1035 assembler.Return( |
1030 assembler->HasProperty(object, key, context, Runtime::kHasProperty)); | 1036 assembler.HasProperty(object, key, context, Runtime::kHasProperty)); |
1031 } | 1037 } |
1032 | 1038 |
1033 void Builtins::Generate_ForInFilter(CodeStubAssembler* assembler) { | 1039 void Builtins::Generate_ForInFilter(compiler::CodeAssemblerState* state) { |
1034 typedef compiler::Node Node; | 1040 typedef compiler::Node Node; |
1035 typedef ForInFilterDescriptor Descriptor; | 1041 typedef ForInFilterDescriptor Descriptor; |
| 1042 CodeStubAssembler assembler(state); |
1036 | 1043 |
1037 Node* key = assembler->Parameter(Descriptor::kKey); | 1044 Node* key = assembler.Parameter(Descriptor::kKey); |
1038 Node* object = assembler->Parameter(Descriptor::kObject); | 1045 Node* object = assembler.Parameter(Descriptor::kObject); |
1039 Node* context = assembler->Parameter(Descriptor::kContext); | 1046 Node* context = assembler.Parameter(Descriptor::kContext); |
1040 | 1047 |
1041 assembler->Return(assembler->ForInFilter(key, object, context)); | 1048 assembler.Return(assembler.ForInFilter(key, object, context)); |
1042 } | 1049 } |
1043 | 1050 |
1044 void Builtins::Generate_InstanceOf(CodeStubAssembler* assembler) { | 1051 void Builtins::Generate_InstanceOf(compiler::CodeAssemblerState* state) { |
1045 typedef compiler::Node Node; | 1052 typedef compiler::Node Node; |
1046 typedef CompareDescriptor Descriptor; | 1053 typedef CompareDescriptor Descriptor; |
1047 Node* object = assembler->Parameter(Descriptor::kLeft); | 1054 CodeStubAssembler assembler(state); |
1048 Node* callable = assembler->Parameter(Descriptor::kRight); | |
1049 Node* context = assembler->Parameter(Descriptor::kContext); | |
1050 | 1055 |
1051 assembler->Return(assembler->InstanceOf(object, callable, context)); | 1056 Node* object = assembler.Parameter(Descriptor::kLeft); |
| 1057 Node* callable = assembler.Parameter(Descriptor::kRight); |
| 1058 Node* context = assembler.Parameter(Descriptor::kContext); |
| 1059 |
| 1060 assembler.Return(assembler.InstanceOf(object, callable, context)); |
1052 } | 1061 } |
1053 | 1062 |
1054 } // namespace internal | 1063 } // namespace internal |
1055 } // namespace v8 | 1064 } // namespace v8 |
OLD | NEW |