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

Side by Side Diff: src/stub-cache.cc

Issue 341453003: Support symbol-named properties in API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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-printer.cc ('k') | test/cctest/test-api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 453
454 // ------------------------------------------------------------------------ 454 // ------------------------------------------------------------------------
455 // StubCompiler implementation. 455 // StubCompiler implementation.
456 456
457 457
458 RUNTIME_FUNCTION(StoreCallbackProperty) { 458 RUNTIME_FUNCTION(StoreCallbackProperty) {
459 JSObject* receiver = JSObject::cast(args[0]); 459 JSObject* receiver = JSObject::cast(args[0]);
460 JSObject* holder = JSObject::cast(args[1]); 460 JSObject* holder = JSObject::cast(args[1]);
461 ExecutableAccessorInfo* callback = ExecutableAccessorInfo::cast(args[2]); 461 ExecutableAccessorInfo* callback = ExecutableAccessorInfo::cast(args[2]);
462 Address setter_address = v8::ToCData<Address>(callback->setter()); 462 Address setter_address = v8::ToCData<Address>(callback->setter());
463 v8::AccessorSetterCallback fun =
464 FUNCTION_CAST<v8::AccessorSetterCallback>(setter_address);
465 ASSERT(fun != NULL);
466 ASSERT(callback->IsCompatibleReceiver(receiver));
467 Handle<Name> name = args.at<Name>(3); 463 Handle<Name> name = args.at<Name>(3);
468 Handle<Object> value = args.at<Object>(4); 464 Handle<Object> value = args.at<Object>(4);
469 HandleScope scope(isolate); 465 HandleScope scope(isolate);
470 466
471 // TODO(rossberg): Support symbols in the API. 467 LOG(isolate, ApiNamedPropertyAccess("store", receiver, *name));
472 if (name->IsSymbol()) return *value; 468 ASSERT(callback->IsCompatibleReceiver(receiver));
473 Handle<String> str = Handle<String>::cast(name);
474 469
475 LOG(isolate, ApiNamedPropertyAccess("store", receiver, *name));
476 PropertyCallbackArguments 470 PropertyCallbackArguments
477 custom_args(isolate, callback->data(), receiver, holder); 471 custom_args(isolate, callback->data(), receiver, holder);
478 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); 472
473 if (name->IsSymbol()) {
474 v8::AccessorSymbolSetterCallback fun =
475 FUNCTION_CAST<v8::AccessorSymbolSetterCallback>(setter_address);
476 Handle<Symbol> sym = Handle<Symbol>::cast(name);
477 ASSERT(fun != NULL);
478 custom_args.Call(fun, v8::Utils::ToLocal(sym), v8::Utils::ToLocal(value));
479 } else {
480 v8::AccessorSetterCallback fun =
481 FUNCTION_CAST<v8::AccessorSetterCallback>(setter_address);
482 ASSERT(fun != NULL);
483 Handle<String> str = Handle<String>::cast(name);
484 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value));
485 }
486
479 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 487 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
480 return *value; 488 return *value;
481 } 489 }
482 490
483 491
484 /** 492 /**
485 * Attempts to load a property with an interceptor (which must be present), 493 * Attempts to load a property with an interceptor (which must be present),
486 * but doesn't search the prototype chain. 494 * but doesn't search the prototype chain.
487 * 495 *
488 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't 496 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
489 * provide any value for the given name. 497 * provide any value for the given name.
490 */ 498 */
491 RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) { 499 RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
492 ASSERT(args.length() == StubCache::kInterceptorArgsLength); 500 ASSERT(args.length() == StubCache::kInterceptorArgsLength);
493 Handle<Name> name_handle = 501 Handle<Name> name =
494 args.at<Name>(StubCache::kInterceptorArgsNameIndex); 502 args.at<Name>(StubCache::kInterceptorArgsNameIndex);
495 Handle<InterceptorInfo> interceptor_info = 503 Handle<InterceptorInfo> interceptor_info =
496 args.at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); 504 args.at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex);
497 505
498 // TODO(rossberg): Support symbols in the API. 506 if (name->IsSymbol() && !interceptor_info->can_intercept_symbols())
499 if (name_handle->IsSymbol())
500 return isolate->heap()->no_interceptor_result_sentinel(); 507 return isolate->heap()->no_interceptor_result_sentinel();
501 Handle<String> name = Handle<String>::cast(name_handle);
502 508
503 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); 509 Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
504 v8::NamedPropertyGetterCallback getter = 510 v8::GenericNamedPropertyGetterCallback getter =
505 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); 511 FUNCTION_CAST<v8::GenericNamedPropertyGetterCallback>(getter_address);
506 ASSERT(getter != NULL); 512 ASSERT(getter != NULL);
507 513
508 Handle<JSObject> receiver = 514 Handle<JSObject> receiver =
509 args.at<JSObject>(StubCache::kInterceptorArgsThisIndex); 515 args.at<JSObject>(StubCache::kInterceptorArgsThisIndex);
510 Handle<JSObject> holder = 516 Handle<JSObject> holder =
511 args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex); 517 args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex);
512 PropertyCallbackArguments callback_args( 518 PropertyCallbackArguments callback_args(
513 isolate, interceptor_info->data(), *receiver, *holder); 519 isolate, interceptor_info->data(), *receiver, *holder);
514 { 520 {
515 // Use the interceptor getter. 521 // Use the interceptor getter.
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 Handle<FunctionTemplateInfo>( 1432 Handle<FunctionTemplateInfo>(
1427 FunctionTemplateInfo::cast(signature->receiver())); 1433 FunctionTemplateInfo::cast(signature->receiver()));
1428 } 1434 }
1429 } 1435 }
1430 1436
1431 is_simple_api_call_ = true; 1437 is_simple_api_call_ = true;
1432 } 1438 }
1433 1439
1434 1440
1435 } } // namespace v8::internal 1441 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698