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/code-stub-assembler.h" | 9 #include "src/code-stub-assembler.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 // 3. Let len be ToLength(Get(O, "length")). | 448 // 3. Let len be ToLength(Get(O, "length")). |
449 // 4. ReturnIfAbrupt(len). | 449 // 4. ReturnIfAbrupt(len). |
450 Variable merged_length(this, MachineRepresentation::kTagged); | 450 Variable merged_length(this, MachineRepresentation::kTagged); |
451 Label has_length(this, &merged_length), not_js_array(this); | 451 Label has_length(this, &merged_length), not_js_array(this); |
452 GotoIf(DoesntHaveInstanceType(o, JS_ARRAY_TYPE), ¬_js_array); | 452 GotoIf(DoesntHaveInstanceType(o, JS_ARRAY_TYPE), ¬_js_array); |
453 merged_length.Bind(LoadJSArrayLength(o)); | 453 merged_length.Bind(LoadJSArrayLength(o)); |
454 Goto(&has_length); | 454 Goto(&has_length); |
455 Bind(¬_js_array); | 455 Bind(¬_js_array); |
456 Node* len_property = | 456 Node* len_property = |
457 CallStub(CodeFactory::GetProperty(isolate()), context, o, | 457 GetProperty(context, o, isolate()->factory()->length_string()); |
458 HeapConstant(isolate()->factory()->length_string())); | |
459 merged_length.Bind( | 458 merged_length.Bind( |
460 CallStub(CodeFactory::ToLength(isolate()), context, len_property)); | 459 CallStub(CodeFactory::ToLength(isolate()), context, len_property)); |
461 Goto(&has_length); | 460 Goto(&has_length); |
462 Bind(&has_length); | 461 Bind(&has_length); |
463 Node* len = merged_length.value(); | 462 Node* len = merged_length.value(); |
464 | 463 |
465 // 5. If IsCallable(callbackfn) is false, throw a TypeError exception. | 464 // 5. If IsCallable(callbackfn) is false, throw a TypeError exception. |
466 Label type_exception(this, Label::kDeferred); | 465 Label type_exception(this, Label::kDeferred); |
467 Label done(this); | 466 Label done(this); |
468 GotoIf(TaggedIsSmi(callbackfn), &type_exception); | 467 GotoIf(TaggedIsSmi(callbackfn), &type_exception); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // b. Let kPresent be HasProperty(O, Pk). | 513 // b. Let kPresent be HasProperty(O, Pk). |
515 // c. ReturnIfAbrupt(kPresent). | 514 // c. ReturnIfAbrupt(kPresent). |
516 Node* k_present = | 515 Node* k_present = |
517 CallStub(CodeFactory::HasProperty(isolate()), context, p_k, o); | 516 CallStub(CodeFactory::HasProperty(isolate()), context, p_k, o); |
518 | 517 |
519 // d. If kPresent is true, then | 518 // d. If kPresent is true, then |
520 GotoIf(WordNotEqual(k_present, TrueConstant()), &done_element); | 519 GotoIf(WordNotEqual(k_present, TrueConstant()), &done_element); |
521 | 520 |
522 // i. Let kValue be Get(O, Pk). | 521 // i. Let kValue be Get(O, Pk). |
523 // ii. ReturnIfAbrupt(kValue). | 522 // ii. ReturnIfAbrupt(kValue). |
524 Node* k_value = CallStub(CodeFactory::GetProperty(isolate()), context, | 523 Node* k_value = GetProperty(context, o, k.value()); |
525 o, k.value()); | |
526 | 524 |
527 // iii. Let funcResult be Call(callbackfn, T, «kValue, k, O»). | 525 // iii. Let funcResult be Call(callbackfn, T, «kValue, k, O»). |
528 // iv. ReturnIfAbrupt(funcResult). | 526 // iv. ReturnIfAbrupt(funcResult). |
529 Node* result = CallJS(CodeFactory::Call(isolate()), context, callbackfn, | 527 Node* result = CallJS(CodeFactory::Call(isolate()), context, callbackfn, |
530 this_arg, k_value, k.value(), o); | 528 this_arg, k_value, k.value(), o); |
531 | 529 |
532 processor(a, p_k, result); | 530 processor(a, p_k, result); |
533 Goto(&done_element); | 531 Goto(&done_element); |
534 Bind(&done_element); | 532 Bind(&done_element); |
535 | 533 |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 Node* invalid = | 2511 Node* invalid = |
2514 SmiConstant(Smi::FromInt(Isolate::kProtectorInvalid)); | 2512 SmiConstant(Smi::FromInt(Isolate::kProtectorInvalid)); |
2515 Node* cell = LoadRoot(Heap::kFastArrayIterationProtectorRootIndex); | 2513 Node* cell = LoadRoot(Heap::kFastArrayIterationProtectorRootIndex); |
2516 StoreObjectFieldNoWriteBarrier(cell, Cell::kValueOffset, invalid); | 2514 StoreObjectFieldNoWriteBarrier(cell, Cell::kValueOffset, invalid); |
2517 Goto(&done); | 2515 Goto(&done); |
2518 } | 2516 } |
2519 } | 2517 } |
2520 | 2518 |
2521 Bind(&if_isnotarray); | 2519 Bind(&if_isnotarray); |
2522 { | 2520 { |
2523 Node* length_string = HeapConstant(factory()->length_string()); | 2521 Node* length = |
2524 Callable get_property = CodeFactory::GetProperty(isolate()); | 2522 GetProperty(context, array, factory()->length_string()); |
2525 Node* length = CallStub(get_property, context, array, length_string); | |
2526 Callable to_length = CodeFactory::ToLength(isolate()); | 2523 Callable to_length = CodeFactory::ToLength(isolate()); |
2527 var_length.Bind(CallStub(to_length, context, length)); | 2524 var_length.Bind(CallStub(to_length, context, length)); |
2528 Goto(&done); | 2525 Goto(&done); |
2529 } | 2526 } |
2530 | 2527 |
2531 Bind(&done); | 2528 Bind(&done); |
2532 length = var_length.value(); | 2529 length = var_length.value(); |
2533 } | 2530 } |
2534 | 2531 |
2535 GotoUnlessNumberLessThan(index, length, &set_done); | 2532 GotoUnlessNumberLessThan(index, length, &set_done); |
2536 | 2533 |
2537 StoreObjectField(iterator, JSArrayIterator::kNextIndexOffset, | 2534 StoreObjectField(iterator, JSArrayIterator::kNextIndexOffset, |
2538 NumberInc(index)); | 2535 NumberInc(index)); |
2539 var_done.Bind(FalseConstant()); | 2536 var_done.Bind(FalseConstant()); |
2540 | 2537 |
2541 Branch( | 2538 Branch( |
2542 Uint32LessThanOrEqual( | 2539 Uint32LessThanOrEqual( |
2543 instance_type, Int32Constant(JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE)), | 2540 instance_type, Int32Constant(JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE)), |
2544 &allocate_key_result, &generic_values); | 2541 &allocate_key_result, &generic_values); |
2545 | 2542 |
2546 Bind(&generic_values); | 2543 Bind(&generic_values); |
2547 { | 2544 { |
2548 Callable get_property = CodeFactory::GetProperty(isolate()); | 2545 var_value.Bind(GetProperty(context, array, index)); |
2549 var_value.Bind(CallStub(get_property, context, array, index)); | |
2550 Goto(&allocate_entry_if_needed); | 2546 Goto(&allocate_entry_if_needed); |
2551 } | 2547 } |
2552 } | 2548 } |
2553 | 2549 |
2554 Bind(&if_istypedarray); | 2550 Bind(&if_istypedarray); |
2555 { | 2551 { |
2556 Node* buffer = LoadObjectField(array, JSTypedArray::kBufferOffset); | 2552 Node* buffer = LoadObjectField(array, JSTypedArray::kBufferOffset); |
2557 GotoIf(IsDetachedBuffer(buffer), &if_isdetached); | 2553 GotoIf(IsDetachedBuffer(buffer), &if_isdetached); |
2558 | 2554 |
2559 Node* length = LoadObjectField(array, JSTypedArray::kLengthOffset); | 2555 Node* length = LoadObjectField(array, JSTypedArray::kLengthOffset); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 { | 2739 { |
2744 Node* message = SmiConstant(MessageTemplate::kDetachedOperation); | 2740 Node* message = SmiConstant(MessageTemplate::kDetachedOperation); |
2745 CallRuntime(Runtime::kThrowTypeError, context, message, | 2741 CallRuntime(Runtime::kThrowTypeError, context, message, |
2746 HeapConstant(operation)); | 2742 HeapConstant(operation)); |
2747 Unreachable(); | 2743 Unreachable(); |
2748 } | 2744 } |
2749 } | 2745 } |
2750 | 2746 |
2751 } // namespace internal | 2747 } // namespace internal |
2752 } // namespace v8 | 2748 } // namespace v8 |
OLD | NEW |