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

Side by Side Diff: src/objects.cc

Issue 231973004: Reland r20652 "Handlify and convert string.length to new API-style accessor." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Allow overwriting 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/bootstrapper.cc ('k') | src/serialize.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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 Handle<DeclaredAccessorInfo>::cast(structure), 412 Handle<DeclaredAccessorInfo>::cast(structure),
413 isolate); 413 isolate);
414 } 414 }
415 415
416 Handle<ExecutableAccessorInfo> data = 416 Handle<ExecutableAccessorInfo> data =
417 Handle<ExecutableAccessorInfo>::cast(structure); 417 Handle<ExecutableAccessorInfo>::cast(structure);
418 v8::AccessorGetterCallback call_fun = 418 v8::AccessorGetterCallback call_fun =
419 v8::ToCData<v8::AccessorGetterCallback>(data->getter()); 419 v8::ToCData<v8::AccessorGetterCallback>(data->getter());
420 if (call_fun == NULL) return isolate->factory()->undefined_value(); 420 if (call_fun == NULL) return isolate->factory()->undefined_value();
421 421
422 Handle<JSObject> self = Handle<JSObject>::cast(receiver);
423 Handle<String> key = Handle<String>::cast(name); 422 Handle<String> key = Handle<String>::cast(name);
424 LOG(isolate, ApiNamedPropertyAccess("load", *self, *name)); 423 LOG(isolate, ApiNamedPropertyAccess("load", *object, *name));
425 PropertyCallbackArguments args(isolate, data->data(), *self, *object); 424 PropertyCallbackArguments args(isolate, data->data(), *receiver, *object);
426 v8::Handle<v8::Value> result = 425 v8::Handle<v8::Value> result =
427 args.Call(call_fun, v8::Utils::ToLocal(key)); 426 args.Call(call_fun, v8::Utils::ToLocal(key));
428 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 427 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
429 if (result.IsEmpty()) { 428 if (result.IsEmpty()) {
430 return isolate->factory()->undefined_value(); 429 return isolate->factory()->undefined_value();
431 } 430 }
432 Handle<Object> return_value = v8::Utils::OpenHandle(*result); 431 Handle<Object> return_value = v8::Utils::OpenHandle(*result);
433 return_value->VerifyApiCallResultType(); 432 return_value->VerifyApiCallResultType();
434 // Rebox handle before return. 433 // Rebox handle before return.
435 return handle(*return_value, isolate); 434 return handle(*return_value, isolate);
(...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 return isolate->Throw<Object>(error); 2876 return isolate->Throw<Object>(error);
2878 } 2877 }
2879 // TODO(rossberg): Support symbols in the API. 2878 // TODO(rossberg): Support symbols in the API.
2880 if (name->IsSymbol()) return value; 2879 if (name->IsSymbol()) return value;
2881 Object* call_obj = data->setter(); 2880 Object* call_obj = data->setter();
2882 v8::AccessorSetterCallback call_fun = 2881 v8::AccessorSetterCallback call_fun =
2883 v8::ToCData<v8::AccessorSetterCallback>(call_obj); 2882 v8::ToCData<v8::AccessorSetterCallback>(call_obj);
2884 if (call_fun == NULL) return value; 2883 if (call_fun == NULL) return value;
2885 Handle<String> key = Handle<String>::cast(name); 2884 Handle<String> key = Handle<String>::cast(name);
2886 LOG(isolate, ApiNamedPropertyAccess("store", *object, *name)); 2885 LOG(isolate, ApiNamedPropertyAccess("store", *object, *name));
2887 PropertyCallbackArguments args( 2886 PropertyCallbackArguments args(isolate, data->data(), *object, *holder);
2888 isolate, data->data(), *object, JSObject::cast(*holder));
2889 args.Call(call_fun, 2887 args.Call(call_fun,
2890 v8::Utils::ToLocal(key), 2888 v8::Utils::ToLocal(key),
2891 v8::Utils::ToLocal(value)); 2889 v8::Utils::ToLocal(value));
2892 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 2890 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
2893 return value; 2891 return value;
2894 } 2892 }
2895 2893
2896 if (structure->IsAccessorPair()) { 2894 if (structure->IsAccessorPair()) {
2897 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); 2895 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
2898 if (setter->IsSpecFunction()) { 2896 if (setter->IsSpecFunction()) {
(...skipping 9231 matching lines...) Expand 10 before | Expand all | Expand 10 after
12130 ASSERT(!structure->IsForeign()); 12128 ASSERT(!structure->IsForeign());
12131 12129
12132 // api style callbacks. 12130 // api style callbacks.
12133 if (structure->IsExecutableAccessorInfo()) { 12131 if (structure->IsExecutableAccessorInfo()) {
12134 Handle<ExecutableAccessorInfo> data = 12132 Handle<ExecutableAccessorInfo> data =
12135 Handle<ExecutableAccessorInfo>::cast(structure); 12133 Handle<ExecutableAccessorInfo>::cast(structure);
12136 Object* fun_obj = data->getter(); 12134 Object* fun_obj = data->getter();
12137 v8::AccessorGetterCallback call_fun = 12135 v8::AccessorGetterCallback call_fun =
12138 v8::ToCData<v8::AccessorGetterCallback>(fun_obj); 12136 v8::ToCData<v8::AccessorGetterCallback>(fun_obj);
12139 if (call_fun == NULL) return isolate->factory()->undefined_value(); 12137 if (call_fun == NULL) return isolate->factory()->undefined_value();
12140 Handle<JSObject> self = Handle<JSObject>::cast(receiver);
12141 Handle<JSObject> holder_handle = Handle<JSObject>::cast(holder); 12138 Handle<JSObject> holder_handle = Handle<JSObject>::cast(holder);
12142 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 12139 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12143 Handle<String> key = isolate->factory()->NumberToString(number); 12140 Handle<String> key = isolate->factory()->NumberToString(number);
12144 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); 12141 LOG(isolate, ApiNamedPropertyAccess("load", *holder_handle, *key));
12145 PropertyCallbackArguments 12142 PropertyCallbackArguments
12146 args(isolate, data->data(), *self, *holder_handle); 12143 args(isolate, data->data(), *receiver, *holder_handle);
12147 v8::Handle<v8::Value> result = args.Call(call_fun, v8::Utils::ToLocal(key)); 12144 v8::Handle<v8::Value> result = args.Call(call_fun, v8::Utils::ToLocal(key));
12148 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 12145 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
12149 if (result.IsEmpty()) return isolate->factory()->undefined_value(); 12146 if (result.IsEmpty()) return isolate->factory()->undefined_value();
12150 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); 12147 Handle<Object> result_internal = v8::Utils::OpenHandle(*result);
12151 result_internal->VerifyApiCallResultType(); 12148 result_internal->VerifyApiCallResultType();
12152 // Rebox handle before return. 12149 // Rebox handle before return.
12153 return handle(*result_internal, isolate); 12150 return handle(*result_internal, isolate);
12154 } 12151 }
12155 12152
12156 // __defineGetter__ callback 12153 // __defineGetter__ callback
(...skipping 4437 matching lines...) Expand 10 before | Expand all | Expand 10 after
16594 #define ERROR_MESSAGES_TEXTS(C, T) T, 16591 #define ERROR_MESSAGES_TEXTS(C, T) T,
16595 static const char* error_messages_[] = { 16592 static const char* error_messages_[] = {
16596 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16593 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16597 }; 16594 };
16598 #undef ERROR_MESSAGES_TEXTS 16595 #undef ERROR_MESSAGES_TEXTS
16599 return error_messages_[reason]; 16596 return error_messages_[reason];
16600 } 16597 }
16601 16598
16602 16599
16603 } } // namespace v8::internal 16600 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698