Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: src/builtins.cc

Issue 204603003: ElementsAccessor::SetLength() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/elements.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 uint32_t key, 541 uint32_t key,
542 Handle<FixedArrayBase> backing_store = Handle<FixedArrayBase>::null()) { 542 Handle<FixedArrayBase> backing_store = Handle<FixedArrayBase>::null()) {
543 CALL_HEAP_FUNCTION(isolate, 543 CALL_HEAP_FUNCTION(isolate,
544 accessor->Get(*receiver, *holder, key, 544 accessor->Get(*receiver, *holder, key,
545 backing_store.is_null() 545 backing_store.is_null()
546 ? *backing_store : NULL), 546 ? *backing_store : NULL),
547 Object); 547 Object);
548 } 548 }
549 549
550 550
551 // TODO(ishell): Temporary wrapper until handlified.
552 static Handle<Object> ElementsAccessorSetLengthWrapper(
553 Isolate* isolate,
554 ElementsAccessor* accessor,
555 Handle<JSArray> array,
556 int new_length) {
557 CALL_HEAP_FUNCTION(isolate,
558 accessor->SetLength(*array, Smi::FromInt(new_length)),
559 Object);
560 }
561
562
563 BUILTIN(ArrayPop) { 551 BUILTIN(ArrayPop) {
564 HandleScope scope(isolate); 552 HandleScope scope(isolate);
565 Handle<Object> receiver = args.receiver(); 553 Handle<Object> receiver = args.receiver();
566 Handle<Object> elms_or_null = 554 Handle<Object> elms_or_null =
567 EnsureJSArrayWithWritableFastElementsWrapper(isolate, receiver, NULL, 0); 555 EnsureJSArrayWithWritableFastElementsWrapper(isolate, receiver, NULL, 0);
568 RETURN_IF_EMPTY_HANDLE(isolate, elms_or_null); 556 RETURN_IF_EMPTY_HANDLE(isolate, elms_or_null);
569 if (*elms_or_null == NULL) return CallJsBuiltin(isolate, "ArrayPop", args); 557 if (*elms_or_null == NULL) return CallJsBuiltin(isolate, "ArrayPop", args);
570 558
571 Handle<FixedArrayBase> elms_obj = Handle<FixedArrayBase>::cast(elms_or_null); 559 Handle<FixedArrayBase> elms_obj = Handle<FixedArrayBase>::cast(elms_or_null);
572 Handle<JSArray> array = Handle<JSArray>::cast(receiver); 560 Handle<JSArray> array = Handle<JSArray>::cast(receiver);
573 ASSERT(!array->map()->is_observed()); 561 ASSERT(!array->map()->is_observed());
574 562
575 int len = Smi::cast(array->length())->value(); 563 int len = Smi::cast(array->length())->value();
576 if (len == 0) return isolate->heap()->undefined_value(); 564 if (len == 0) return isolate->heap()->undefined_value();
577 565
578 ElementsAccessor* accessor = array->GetElementsAccessor(); 566 ElementsAccessor* accessor = array->GetElementsAccessor();
579 int new_length = len - 1; 567 int new_length = len - 1;
580 Handle<Object> element; 568 Handle<Object> element;
581 if (ElementsAccessorHasElementWrapper( 569 if (ElementsAccessorHasElementWrapper(
582 accessor, array, array, new_length, elms_obj)) { 570 accessor, array, array, new_length, elms_obj)) {
583 element = ElementsAccessorGetWrapper( 571 element = ElementsAccessorGetWrapper(
584 isolate, accessor, array, array, new_length, elms_obj); 572 isolate, accessor, array, array, new_length, elms_obj);
585 } else { 573 } else {
586 Handle<Object> proto(array->GetPrototype(), isolate); 574 Handle<Object> proto(array->GetPrototype(), isolate);
587 element = Object::GetElement(isolate, proto, len - 1); 575 element = Object::GetElement(isolate, proto, len - 1);
588 } 576 }
589 RETURN_IF_EMPTY_HANDLE(isolate, element); 577 RETURN_IF_EMPTY_HANDLE(isolate, element);
590 RETURN_IF_EMPTY_HANDLE(isolate, 578 RETURN_IF_EMPTY_HANDLE(isolate,
591 ElementsAccessorSetLengthWrapper( 579 accessor->SetLength(
592 isolate, accessor, array, new_length)); 580 array, handle(Smi::FromInt(new_length), isolate)));
593 return *element; 581 return *element;
594 } 582 }
595 583
596 584
597 BUILTIN(ArrayShift) { 585 BUILTIN(ArrayShift) {
598 Heap* heap = isolate->heap(); 586 Heap* heap = isolate->heap();
599 Object* receiver = *args.receiver(); 587 Object* receiver = *args.receiver();
600 FixedArrayBase* elms_obj; 588 FixedArrayBase* elms_obj;
601 MaybeObject* maybe_elms_obj = 589 MaybeObject* maybe_elms_obj =
602 EnsureJSArrayWithWritableFastElements(heap, receiver, NULL, 0); 590 EnsureJSArrayWithWritableFastElements(heap, receiver, NULL, 0);
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 } 1782 }
1795 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1783 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1796 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1784 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1797 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1785 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1798 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1786 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1799 #undef DEFINE_BUILTIN_ACCESSOR_C 1787 #undef DEFINE_BUILTIN_ACCESSOR_C
1800 #undef DEFINE_BUILTIN_ACCESSOR_A 1788 #undef DEFINE_BUILTIN_ACCESSOR_A
1801 1789
1802 1790
1803 } } // namespace v8::internal 1791 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698