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

Side by Side Diff: src/objects.cc

Issue 225683003: ElementsAccessor::GetAccessorPair() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ElementsAccessor::GetAccessorPair() handlified. Created 6 years, 8 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/objects.h ('k') | src/runtime.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 5174 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 if (proto->IsNull()) return factory->false_value(); 5185 if (proto->IsNull()) return factory->false_value();
5186 ASSERT(proto->IsJSGlobalObject()); 5186 ASSERT(proto->IsJSGlobalObject());
5187 return DeleteElement(Handle<JSObject>::cast(proto), index, mode); 5187 return DeleteElement(Handle<JSObject>::cast(proto), index, mode);
5188 } 5188 }
5189 5189
5190 Handle<Object> old_value; 5190 Handle<Object> old_value;
5191 bool should_enqueue_change_record = false; 5191 bool should_enqueue_change_record = false;
5192 if (object->map()->is_observed()) { 5192 if (object->map()->is_observed()) {
5193 should_enqueue_change_record = HasLocalElement(object, index); 5193 should_enqueue_change_record = HasLocalElement(object, index);
5194 if (should_enqueue_change_record) { 5194 if (should_enqueue_change_record) {
5195 if (object->GetLocalElementAccessorPair(index) != NULL) { 5195 if (!GetLocalElementAccessorPair(object, index).is_null()) {
5196 old_value = Handle<Object>::cast(factory->the_hole_value()); 5196 old_value = Handle<Object>::cast(factory->the_hole_value());
5197 } else { 5197 } else {
5198 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); 5198 old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
5199 } 5199 }
5200 } 5200 }
5201 } 5201 }
5202 5202
5203 // Skip interceptor if forcing deletion. 5203 // Skip interceptor if forcing deletion.
5204 Handle<Object> result; 5204 Handle<Object> result;
5205 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { 5205 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) {
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
6364 uint32_t index = 0; 6364 uint32_t index = 0;
6365 bool is_element = name->AsArrayIndex(&index); 6365 bool is_element = name->AsArrayIndex(&index);
6366 6366
6367 Handle<Object> old_value = isolate->factory()->the_hole_value(); 6367 Handle<Object> old_value = isolate->factory()->the_hole_value();
6368 bool is_observed = object->map()->is_observed() && 6368 bool is_observed = object->map()->is_observed() &&
6369 *name != isolate->heap()->hidden_string(); 6369 *name != isolate->heap()->hidden_string();
6370 bool preexists = false; 6370 bool preexists = false;
6371 if (is_observed) { 6371 if (is_observed) {
6372 if (is_element) { 6372 if (is_element) {
6373 preexists = HasLocalElement(object, index); 6373 preexists = HasLocalElement(object, index);
6374 if (preexists && object->GetLocalElementAccessorPair(index) == NULL) { 6374 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) {
6375 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); 6375 old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
6376 } 6376 }
6377 } else { 6377 } else {
6378 LookupResult lookup(isolate); 6378 LookupResult lookup(isolate);
6379 object->LocalLookup(*name, &lookup, true); 6379 object->LocalLookup(*name, &lookup, true);
6380 preexists = lookup.IsProperty(); 6380 preexists = lookup.IsProperty();
6381 if (preexists && lookup.IsDataProperty()) { 6381 if (preexists && lookup.IsDataProperty()) {
6382 old_value = Object::GetPropertyOrElement(object, name); 6382 old_value = Object::GetPropertyOrElement(object, name);
6383 CHECK_NOT_EMPTY_HANDLE(isolate, old_value); 6383 CHECK_NOT_EMPTY_HANDLE(isolate, old_value);
6384 } 6384 }
(...skipping 4927 matching lines...) Expand 10 before | Expand all | Expand 10 after
11312 static bool GetOldValue(Isolate* isolate, 11312 static bool GetOldValue(Isolate* isolate,
11313 Handle<JSObject> object, 11313 Handle<JSObject> object,
11314 uint32_t index, 11314 uint32_t index,
11315 List<Handle<Object> >* old_values, 11315 List<Handle<Object> >* old_values,
11316 List<uint32_t>* indices) { 11316 List<uint32_t>* indices) {
11317 PropertyAttributes attributes = 11317 PropertyAttributes attributes =
11318 JSReceiver::GetLocalElementAttribute(object, index); 11318 JSReceiver::GetLocalElementAttribute(object, index);
11319 ASSERT(attributes != ABSENT); 11319 ASSERT(attributes != ABSENT);
11320 if (attributes == DONT_DELETE) return false; 11320 if (attributes == DONT_DELETE) return false;
11321 Handle<Object> value; 11321 Handle<Object> value;
11322 if (object->GetLocalElementAccessorPair(index) != NULL) { 11322 if (!JSObject::GetLocalElementAccessorPair(object, index).is_null()) {
11323 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); 11323 value = Handle<Object>::cast(isolate->factory()->the_hole_value());
11324 } else { 11324 } else {
11325 value = Object::GetElementNoExceptionThrown(isolate, object, index); 11325 value = Object::GetElementNoExceptionThrown(isolate, object, index);
11326 } 11326 }
11327 old_values->Add(value); 11327 old_values->Add(value);
11328 indices->Add(index); 11328 indices->Add(index);
11329 return true; 11329 return true;
11330 } 11330 }
11331 11331
11332 static void EnqueueSpliceRecord(Handle<JSArray> object, 11332 static void EnqueueSpliceRecord(Handle<JSArray> object,
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
11851 uint32_t arg_count, 11851 uint32_t arg_count,
11852 EnsureElementsMode mode) { 11852 EnsureElementsMode mode) {
11853 // Elements in |Arguments| are ordered backwards (because they're on the 11853 // Elements in |Arguments| are ordered backwards (because they're on the
11854 // stack), but the method that's called here iterates over them in forward 11854 // stack), but the method that's called here iterates over them in forward
11855 // direction. 11855 // direction.
11856 return EnsureCanContainElements( 11856 return EnsureCanContainElements(
11857 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode); 11857 object, args->arguments() - first_arg - (arg_count - 1), arg_count, mode);
11858 } 11858 }
11859 11859
11860 11860
11861 AccessorPair* JSObject::GetLocalPropertyAccessorPair(Name* name) { 11861 MaybeHandle<AccessorPair> JSObject::GetLocalPropertyAccessorPair(
11862 Handle<JSObject> object,
11863 Handle<Name> name) {
11862 uint32_t index = 0; 11864 uint32_t index = 0;
11863 if (name->AsArrayIndex(&index)) { 11865 if (name->AsArrayIndex(&index)) {
11864 return GetLocalElementAccessorPair(index); 11866 return GetLocalElementAccessorPair(object, index);
11865 } 11867 }
11866 11868
11867 LookupResult lookup(GetIsolate()); 11869 Isolate* isolate = object->GetIsolate();
11868 LocalLookupRealNamedProperty(name, &lookup); 11870 LookupResult lookup(isolate);
11871 object->LocalLookupRealNamedProperty(*name, &lookup);
11869 11872
11870 if (lookup.IsPropertyCallbacks() && 11873 if (lookup.IsPropertyCallbacks() &&
11871 lookup.GetCallbackObject()->IsAccessorPair()) { 11874 lookup.GetCallbackObject()->IsAccessorPair()) {
11872 return AccessorPair::cast(lookup.GetCallbackObject()); 11875 return handle(AccessorPair::cast(lookup.GetCallbackObject()), isolate);
11873 } 11876 }
11874 return NULL; 11877 return MaybeHandle<AccessorPair>();
11875 } 11878 }
11876 11879
11877 11880
11878 AccessorPair* JSObject::GetLocalElementAccessorPair(uint32_t index) { 11881 MaybeHandle<AccessorPair> JSObject::GetLocalElementAccessorPair(
11879 if (IsJSGlobalProxy()) { 11882 Handle<JSObject> object,
11880 Object* proto = GetPrototype(); 11883 uint32_t index) {
11881 if (proto->IsNull()) return NULL; 11884 if (object->IsJSGlobalProxy()) {
11885 Handle<Object> proto(object->GetPrototype(), object->GetIsolate());
11886 if (proto->IsNull()) return MaybeHandle<AccessorPair>();
11882 ASSERT(proto->IsJSGlobalObject()); 11887 ASSERT(proto->IsJSGlobalObject());
11883 return JSObject::cast(proto)->GetLocalElementAccessorPair(index); 11888 return GetLocalElementAccessorPair(Handle<JSObject>::cast(proto), index);
11884 } 11889 }
11885 11890
11886 // Check for lookup interceptor. 11891 // Check for lookup interceptor.
11887 if (HasIndexedInterceptor()) return NULL; 11892 if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>();
11888 11893
11889 return GetElementsAccessor()->GetAccessorPair(this, this, index); 11894 return object->GetElementsAccessor()->GetAccessorPair(object, object, index);
11890 } 11895 }
11891 11896
11892 11897
11893 Handle<Object> JSObject::SetElementWithInterceptor( 11898 Handle<Object> JSObject::SetElementWithInterceptor(
11894 Handle<JSObject> object, 11899 Handle<JSObject> object,
11895 uint32_t index, 11900 uint32_t index,
11896 Handle<Object> value, 11901 Handle<Object> value,
11897 PropertyAttributes attributes, 11902 PropertyAttributes attributes,
11898 StrictMode strict_mode, 11903 StrictMode strict_mode,
11899 bool check_prototype, 11904 bool check_prototype,
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
12528 set_mode); 12533 set_mode);
12529 } 12534 }
12530 12535
12531 PropertyAttributes old_attributes = 12536 PropertyAttributes old_attributes =
12532 JSReceiver::GetLocalElementAttribute(object, index); 12537 JSReceiver::GetLocalElementAttribute(object, index);
12533 Handle<Object> old_value = isolate->factory()->the_hole_value(); 12538 Handle<Object> old_value = isolate->factory()->the_hole_value();
12534 Handle<Object> old_length_handle; 12539 Handle<Object> old_length_handle;
12535 Handle<Object> new_length_handle; 12540 Handle<Object> new_length_handle;
12536 12541
12537 if (old_attributes != ABSENT) { 12542 if (old_attributes != ABSENT) {
12538 if (object->GetLocalElementAccessorPair(index) == NULL) { 12543 if (GetLocalElementAccessorPair(object, index).is_null()) {
12539 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); 12544 old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
12540 } 12545 }
12541 } else if (object->IsJSArray()) { 12546 } else if (object->IsJSArray()) {
12542 // Store old array length in case adding an element grows the array. 12547 // Store old array length in case adding an element grows the array.
12543 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), 12548 old_length_handle = handle(Handle<JSArray>::cast(object)->length(),
12544 isolate); 12549 isolate);
12545 } 12550 }
12546 12551
12547 // Check for lookup interceptor 12552 // Check for lookup interceptor
12548 Handle<Object> result = object->HasIndexedInterceptor() 12553 Handle<Object> result = object->HasIndexedInterceptor()
(...skipping 3937 matching lines...) Expand 10 before | Expand all | Expand 10 after
16486 #define ERROR_MESSAGES_TEXTS(C, T) T, 16491 #define ERROR_MESSAGES_TEXTS(C, T) T,
16487 static const char* error_messages_[] = { 16492 static const char* error_messages_[] = {
16488 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16493 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16489 }; 16494 };
16490 #undef ERROR_MESSAGES_TEXTS 16495 #undef ERROR_MESSAGES_TEXTS
16491 return error_messages_[reason]; 16496 return error_messages_[reason];
16492 } 16497 }
16493 16498
16494 16499
16495 } } // namespace v8::internal 16500 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698