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

Side by Side Diff: src/objects.cc

Issue 9605006: Consistently order receiver and holder argument in ElementAccessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« src/elements.cc ('K') | « src/elements.cc ('k') | no next file » | 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return heap->undefined_value(); 685 return heap->undefined_value();
686 } 686 }
687 } 687 }
688 688
689 if (js_object->HasIndexedInterceptor()) { 689 if (js_object->HasIndexedInterceptor()) {
690 return js_object->GetElementWithInterceptor(receiver, index); 690 return js_object->GetElementWithInterceptor(receiver, index);
691 } 691 }
692 692
693 if (js_object->elements() != heap->empty_fixed_array()) { 693 if (js_object->elements() != heap->empty_fixed_array()) {
694 MaybeObject* result = js_object->GetElementsAccessor()->Get( 694 MaybeObject* result = js_object->GetElementsAccessor()->Get(
695 js_object->elements(), 695 receiver, js_object, index);
696 index,
697 js_object,
698 receiver);
699 if (result != heap->the_hole_value()) return result; 696 if (result != heap->the_hole_value()) return result;
700 } 697 }
701 } 698 }
702 699
703 return heap->undefined_value(); 700 return heap->undefined_value();
704 } 701 }
705 702
706 703
707 Object* Object::GetPrototype() { 704 Object* Object::GetPrototype() {
708 if (IsSmi()) { 705 if (IsSmi()) {
(...skipping 4836 matching lines...) Expand 10 before | Expand all | Expand 10 after
5545 cache->set(EntryToIndex(entry), obj); 5542 cache->set(EntryToIndex(entry), obj);
5546 cache->set(EntryToIndex(entry) + 1, code); 5543 cache->set(EntryToIndex(entry) + 1, code);
5547 cache->ElementAdded(); 5544 cache->ElementAdded();
5548 return cache; 5545 return cache;
5549 } 5546 }
5550 5547
5551 5548
5552 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { 5549 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
5553 ElementsAccessor* accessor = array->GetElementsAccessor(); 5550 ElementsAccessor* accessor = array->GetElementsAccessor();
5554 MaybeObject* maybe_result = 5551 MaybeObject* maybe_result =
5555 accessor->AddElementsToFixedArray(array->elements(), this, array, array); 5552 accessor->AddElementsToFixedArray(array, array, this);
5556 FixedArray* result; 5553 FixedArray* result;
5557 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; 5554 if (!maybe_result->To<FixedArray>(&result)) return maybe_result;
5558 #ifdef DEBUG 5555 #ifdef DEBUG
5559 if (FLAG_enable_slow_asserts) { 5556 if (FLAG_enable_slow_asserts) {
5560 for (int i = 0; i < result->length(); i++) { 5557 for (int i = 0; i < result->length(); i++) {
5561 Object* current = result->get(i); 5558 Object* current = result->get(i);
5562 ASSERT(current->IsNumber() || current->IsString()); 5559 ASSERT(current->IsNumber() || current->IsString());
5563 } 5560 }
5564 } 5561 }
5565 #endif 5562 #endif
5566 return result; 5563 return result;
5567 } 5564 }
5568 5565
5569 5566
5570 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { 5567 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
5571 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); 5568 ElementsAccessor* accessor = ElementsAccessor::ForArray(other);
5572 MaybeObject* maybe_result = 5569 MaybeObject* maybe_result =
5573 accessor->AddElementsToFixedArray(other, this, NULL, NULL); 5570 accessor->AddElementsToFixedArray(NULL, NULL, this, other);
5574 FixedArray* result; 5571 FixedArray* result;
5575 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; 5572 if (!maybe_result->To<FixedArray>(&result)) return maybe_result;
5576 #ifdef DEBUG 5573 #ifdef DEBUG
5577 if (FLAG_enable_slow_asserts) { 5574 if (FLAG_enable_slow_asserts) {
5578 for (int i = 0; i < result->length(); i++) { 5575 for (int i = 0; i < result->length(); i++) {
5579 Object* current = result->get(i); 5576 Object* current = result->get(i);
5580 ASSERT(current->IsNumber() || current->IsString()); 5577 ASSERT(current->IsNumber() || current->IsString());
5581 } 5578 }
5582 } 5579 }
5583 #endif 5580 #endif
(...skipping 3326 matching lines...) Expand 10 before | Expand all | Expand 10 after
8910 v8::Handle<v8::Value> result; 8907 v8::Handle<v8::Value> result;
8911 { 8908 {
8912 // Leaving JavaScript. 8909 // Leaving JavaScript.
8913 VMState state(isolate, EXTERNAL); 8910 VMState state(isolate, EXTERNAL);
8914 result = getter(index, info); 8911 result = getter(index, info);
8915 } 8912 }
8916 if (!result.IsEmpty()) return true; 8913 if (!result.IsEmpty()) return true;
8917 } 8914 }
8918 8915
8919 if (holder_handle->GetElementsAccessor()->HasElement( 8916 if (holder_handle->GetElementsAccessor()->HasElement(
8920 holder_handle->elements(), index, *holder_handle, *receiver_handle)) { 8917 *receiver_handle, *holder_handle, index)) {
8921 return true; 8918 return true;
8922 } 8919 }
8923 8920
8924 if (holder_handle->IsStringObjectWithCharacterAt(index)) return true; 8921 if (holder_handle->IsStringObjectWithCharacterAt(index)) return true;
8925 Object* pt = holder_handle->GetPrototype(); 8922 Object* pt = holder_handle->GetPrototype();
8926 if (pt->IsJSProxy()) { 8923 if (pt->IsJSProxy()) {
8927 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. 8924 // We need to follow the spec and simulate a call to [[GetOwnProperty]].
8928 return JSProxy::cast(pt)->GetElementAttributeWithHandler( 8925 return JSProxy::cast(pt)->GetElementAttributeWithHandler(
8929 receiver, index) != ABSENT; 8926 receiver, index) != ABSENT;
8930 } 8927 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
9048 return false; 9045 return false;
9049 } 9046 }
9050 } 9047 }
9051 9048
9052 // Check for lookup interceptor 9049 // Check for lookup interceptor
9053 if (HasIndexedInterceptor()) { 9050 if (HasIndexedInterceptor()) {
9054 return HasElementWithInterceptor(receiver, index); 9051 return HasElementWithInterceptor(receiver, index);
9055 } 9052 }
9056 9053
9057 ElementsAccessor* accessor = GetElementsAccessor(); 9054 ElementsAccessor* accessor = GetElementsAccessor();
9058 if (accessor->HasElement(elements(), index, this, receiver)) { 9055 if (accessor->HasElement(receiver, this, index)) {
9059 return true; 9056 return true;
9060 } 9057 }
9061 9058
9062 // Handle [] on String objects. 9059 // Handle [] on String objects.
9063 if (this->IsStringObjectWithCharacterAt(index)) return true; 9060 if (this->IsStringObjectWithCharacterAt(index)) return true;
9064 9061
9065 Object* pt = GetPrototype(); 9062 Object* pt = GetPrototype();
9066 if (pt->IsNull()) return false; 9063 if (pt->IsNull()) return false;
9067 if (pt->IsJSProxy()) { 9064 if (pt->IsJSProxy()) {
9068 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. 9065 // We need to follow the spec and simulate a call to [[GetOwnProperty]].
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
9909 // Leaving JavaScript. 9906 // Leaving JavaScript.
9910 VMState state(isolate, EXTERNAL); 9907 VMState state(isolate, EXTERNAL);
9911 result = getter(index, info); 9908 result = getter(index, info);
9912 } 9909 }
9913 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 9910 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
9914 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); 9911 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
9915 } 9912 }
9916 9913
9917 Heap* heap = holder_handle->GetHeap(); 9914 Heap* heap = holder_handle->GetHeap();
9918 ElementsAccessor* handler = holder_handle->GetElementsAccessor(); 9915 ElementsAccessor* handler = holder_handle->GetElementsAccessor();
9919 MaybeObject* raw_result = handler->Get(holder_handle->elements(), 9916 MaybeObject* raw_result = handler->Get(*this_handle,
9920 index,
9921 *holder_handle, 9917 *holder_handle,
9922 *this_handle); 9918 index);
9923 if (raw_result != heap->the_hole_value()) return raw_result; 9919 if (raw_result != heap->the_hole_value()) return raw_result;
9924 9920
9925 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 9921 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
9926 9922
9927 Object* pt = holder_handle->GetPrototype(); 9923 Object* pt = holder_handle->GetPrototype();
9928 if (pt == heap->null_value()) return heap->undefined_value(); 9924 if (pt == heap->null_value()) return heap->undefined_value();
9929 return pt->GetElementWithReceiver(*this_handle, index); 9925 return pt->GetElementWithReceiver(*this_handle, index);
9930 } 9926 }
9931 9927
9932 9928
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
12983 if (break_point_objects()->IsUndefined()) return 0; 12979 if (break_point_objects()->IsUndefined()) return 0;
12984 // Single break point. 12980 // Single break point.
12985 if (!break_point_objects()->IsFixedArray()) return 1; 12981 if (!break_point_objects()->IsFixedArray()) return 1;
12986 // Multiple break points. 12982 // Multiple break points.
12987 return FixedArray::cast(break_point_objects())->length(); 12983 return FixedArray::cast(break_point_objects())->length();
12988 } 12984 }
12989 #endif // ENABLE_DEBUGGER_SUPPORT 12985 #endif // ENABLE_DEBUGGER_SUPPORT
12990 12986
12991 12987
12992 } } // namespace v8::internal 12988 } } // namespace v8::internal
OLDNEW
« src/elements.cc ('K') | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698