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

Side by Side Diff: src/objects.cc

Issue 426633002: Encapsulate type in the PropertyHandlerCompiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 403
404 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, 404 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
405 Handle<Name> name, 405 Handle<Name> name,
406 Handle<JSObject> holder, 406 Handle<JSObject> holder,
407 Handle<Object> structure) { 407 Handle<Object> structure) {
408 Isolate* isolate = name->GetIsolate(); 408 Isolate* isolate = name->GetIsolate();
409 ASSERT(!structure->IsForeign()); 409 ASSERT(!structure->IsForeign());
410 // api style callbacks. 410 // api style callbacks.
411 if (structure->IsAccessorInfo()) { 411 if (structure->IsAccessorInfo()) {
412 Handle<AccessorInfo> accessor_info = Handle<AccessorInfo>::cast(structure); 412 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
413 if (!accessor_info->IsCompatibleReceiver(*receiver)) { 413 if (info->HasExpectedReceiverType() &&
414 !(receiver->IsHeapObject() &&
415 info->IsCompatibleReceiver(HeapObject::cast(*receiver)->map()))) {
414 Handle<Object> args[2] = { name, receiver }; 416 Handle<Object> args[2] = { name, receiver };
415 Handle<Object> error = 417 Handle<Object> error =
416 isolate->factory()->NewTypeError("incompatible_method_receiver", 418 isolate->factory()->NewTypeError("incompatible_method_receiver",
417 HandleVector(args, 419 HandleVector(args,
418 ARRAY_SIZE(args))); 420 ARRAY_SIZE(args)));
419 return isolate->Throw<Object>(error); 421 return isolate->Throw<Object>(error);
420 } 422 }
421 // TODO(rossberg): Handling symbols in the API requires changing the API, 423 // TODO(rossberg): Handling symbols in the API requires changing the API,
422 // so we do not support it for now. 424 // so we do not support it for now.
423 if (name->IsSymbol()) return isolate->factory()->undefined_value(); 425 if (name->IsSymbol()) return isolate->factory()->undefined_value();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) { 469 Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) {
468 Isolate* isolate = name->GetIsolate(); 470 Isolate* isolate = name->GetIsolate();
469 471
470 // We should never get here to initialize a const with the hole 472 // We should never get here to initialize a const with the hole
471 // value since a const declaration would conflict with the setter. 473 // value since a const declaration would conflict with the setter.
472 ASSERT(!structure->IsForeign()); 474 ASSERT(!structure->IsForeign());
473 if (structure->IsExecutableAccessorInfo()) { 475 if (structure->IsExecutableAccessorInfo()) {
474 // Don't call executable accessor setters with non-JSObject receivers. 476 // Don't call executable accessor setters with non-JSObject receivers.
475 if (!receiver->IsJSObject()) return value; 477 if (!receiver->IsJSObject()) return value;
476 // api style callbacks 478 // api style callbacks
477 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(*structure); 479 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure);
478 if (!data->IsCompatibleReceiver(*receiver)) { 480 if (info->HasExpectedReceiverType() &&
481 !(receiver->IsHeapObject() &&
482 info->IsCompatibleReceiver(HeapObject::cast(*receiver)->map()))) {
479 Handle<Object> args[2] = { name, receiver }; 483 Handle<Object> args[2] = { name, receiver };
480 Handle<Object> error = 484 Handle<Object> error =
481 isolate->factory()->NewTypeError("incompatible_method_receiver", 485 isolate->factory()->NewTypeError("incompatible_method_receiver",
482 HandleVector(args, 486 HandleVector(args,
483 ARRAY_SIZE(args))); 487 ARRAY_SIZE(args)));
484 return isolate->Throw<Object>(error); 488 return isolate->Throw<Object>(error);
485 } 489 }
486 // TODO(rossberg): Support symbols in the API. 490 // TODO(rossberg): Support symbols in the API.
487 if (name->IsSymbol()) return value; 491 if (name->IsSymbol()) return value;
488 Object* call_obj = data->setter(); 492 Object* call_obj = info->setter();
489 v8::AccessorSetterCallback call_fun = 493 v8::AccessorSetterCallback call_fun =
490 v8::ToCData<v8::AccessorSetterCallback>(call_obj); 494 v8::ToCData<v8::AccessorSetterCallback>(call_obj);
491 if (call_fun == NULL) return value; 495 if (call_fun == NULL) return value;
492 Handle<String> key = Handle<String>::cast(name); 496 Handle<String> key = Handle<String>::cast(name);
493 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); 497 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name));
494 PropertyCallbackArguments args(isolate, data->data(), *receiver, *holder); 498 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder);
495 args.Call(call_fun, 499 args.Call(call_fun,
496 v8::Utils::ToLocal(key), 500 v8::Utils::ToLocal(key),
497 v8::Utils::ToLocal(value)); 501 v8::Utils::ToLocal(value));
498 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 502 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
499 return value; 503 return value;
500 } 504 }
501 505
502 if (structure->IsAccessorPair()) { 506 if (structure->IsAccessorPair()) {
503 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); 507 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
504 if (setter->IsSpecFunction()) { 508 if (setter->IsSpecFunction()) {
(...skipping 16458 matching lines...) Expand 10 before | Expand all | Expand 10 after
16963 #define ERROR_MESSAGES_TEXTS(C, T) T, 16967 #define ERROR_MESSAGES_TEXTS(C, T) T,
16964 static const char* error_messages_[] = { 16968 static const char* error_messages_[] = {
16965 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16969 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16966 }; 16970 };
16967 #undef ERROR_MESSAGES_TEXTS 16971 #undef ERROR_MESSAGES_TEXTS
16968 return error_messages_[reason]; 16972 return error_messages_[reason];
16969 } 16973 }
16970 16974
16971 16975
16972 } } // namespace v8::internal 16976 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698