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

Side by Side Diff: src/builtins.cc

Issue 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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 | « src/bootstrapper.cc ('k') | src/code-stubs.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 static bool ArrayPrototypeHasNoElements(Heap* heap, 366 static bool ArrayPrototypeHasNoElements(Heap* heap,
367 Context* global_context, 367 Context* global_context,
368 JSObject* array_proto) { 368 JSObject* array_proto) {
369 // This method depends on non writability of Object and Array prototype 369 // This method depends on non writability of Object and Array prototype
370 // fields. 370 // fields.
371 if (array_proto->elements() != heap->empty_fixed_array()) return false; 371 if (array_proto->elements() != heap->empty_fixed_array()) return false;
372 // Hidden prototype 372 // Hidden prototype
373 array_proto = JSObject::cast(array_proto->GetPrototype()); 373 array_proto = JSObject::cast(array_proto->GetPrototype());
374 ASSERT(array_proto->elements() == heap->empty_fixed_array()); 374 ASSERT(array_proto->elements() == heap->empty_fixed_array());
375 // Object.prototype 375 // Object.prototype
376 array_proto = JSObject::cast(array_proto->GetPrototype()); 376 Object* proto = array_proto->GetPrototype();
377 if (proto == heap->null_value()) return false;
378 array_proto = JSObject::cast(proto);
377 if (array_proto != global_context->initial_object_prototype()) return false; 379 if (array_proto != global_context->initial_object_prototype()) return false;
378 if (array_proto->elements() != heap->empty_fixed_array()) return false; 380 if (array_proto->elements() != heap->empty_fixed_array()) return false;
379 ASSERT(array_proto->GetPrototype()->IsNull()); 381 ASSERT(array_proto->GetPrototype()->IsNull());
380 return true; 382 return true;
381 } 383 }
382 384
383 385
384 MUST_USE_RESULT 386 MUST_USE_RESULT
385 static inline MaybeObject* EnsureJSArrayWithWritableFastElements( 387 static inline MaybeObject* EnsureJSArrayWithWritableFastElements(
386 Heap* heap, Object* receiver) { 388 Heap* heap, Object* receiver) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 return CallJsBuiltin(isolate, "ArraySplice", args); 748 return CallJsBuiltin(isolate, "ArraySplice", args);
747 } 749 }
748 FixedArray* elms = FixedArray::cast(elms_obj); 750 FixedArray* elms = FixedArray::cast(elms_obj);
749 JSArray* array = JSArray::cast(receiver); 751 JSArray* array = JSArray::cast(receiver);
750 ASSERT(array->HasFastElements()); 752 ASSERT(array->HasFastElements());
751 753
752 int len = Smi::cast(array->length())->value(); 754 int len = Smi::cast(array->length())->value();
753 755
754 int n_arguments = args.length() - 1; 756 int n_arguments = args.length() - 1;
755 757
756 // Return empty array when no arguments are supplied.
757 if (n_arguments == 0) {
758 return AllocateEmptyJSArray(heap);
759 }
760
761 int relative_start = 0; 758 int relative_start = 0;
762 Object* arg1 = args[1]; 759 if (n_arguments > 0) {
763 if (arg1->IsSmi()) { 760 Object* arg1 = args[1];
764 relative_start = Smi::cast(arg1)->value(); 761 if (arg1->IsSmi()) {
765 } else if (!arg1->IsUndefined()) { 762 relative_start = Smi::cast(arg1)->value();
766 return CallJsBuiltin(isolate, "ArraySplice", args); 763 } else if (!arg1->IsUndefined()) {
764 return CallJsBuiltin(isolate, "ArraySplice", args);
765 }
767 } 766 }
768 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) 767 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
769 : Min(relative_start, len); 768 : Min(relative_start, len);
770 769
771 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is 770 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is
772 // given differently from when an undefined delete count is given. 771 // given as a request to delete all the elements from the start.
772 // And it differs from the case of undefined delete count.
773 // This does not follow ECMA-262, but we do the same for 773 // This does not follow ECMA-262, but we do the same for
774 // compatibility. 774 // compatibility.
775 int delete_count = len; 775 int actual_delete_count;
776 if (n_arguments > 1) { 776 if (n_arguments == 1) {
777 Object* arg2 = args[2]; 777 ASSERT(len - actual_start >= 0);
778 if (arg2->IsSmi()) { 778 actual_delete_count = len - actual_start;
779 delete_count = Smi::cast(arg2)->value(); 779 } else {
780 } else { 780 int value = 0; // ToInteger(undefined) == 0
781 return CallJsBuiltin(isolate, "ArraySplice", args); 781 if (n_arguments > 1) {
782 Object* arg2 = args[2];
783 if (arg2->IsSmi()) {
784 value = Smi::cast(arg2)->value();
785 } else {
786 return CallJsBuiltin(isolate, "ArraySplice", args);
787 }
782 } 788 }
789 actual_delete_count = Min(Max(value, 0), len - actual_start);
783 } 790 }
784 int actual_delete_count = Min(Max(delete_count, 0), len - actual_start);
785 791
786 JSArray* result_array = NULL; 792 JSArray* result_array = NULL;
787 if (actual_delete_count == 0) { 793 if (actual_delete_count == 0) {
788 Object* result; 794 Object* result;
789 { MaybeObject* maybe_result = AllocateEmptyJSArray(heap); 795 { MaybeObject* maybe_result = AllocateEmptyJSArray(heap);
790 if (!maybe_result->ToObject(&result)) return maybe_result; 796 if (!maybe_result->ToObject(&result)) return maybe_result;
791 } 797 }
792 result_array = JSArray::cast(result); 798 result_array = JSArray::cast(result);
793 } else { 799 } else {
794 // Allocate result array. 800 // Allocate result array.
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 if (entry->contains(pc)) { 1609 if (entry->contains(pc)) {
1604 return names_[i]; 1610 return names_[i];
1605 } 1611 }
1606 } 1612 }
1607 } 1613 }
1608 return NULL; 1614 return NULL;
1609 } 1615 }
1610 1616
1611 1617
1612 } } // namespace v8::internal 1618 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698