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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 4d08b7999ed27c317b41109f381eafb8d25575c3..24b5614957ac9e1622ffc94405722ff97cf826e1 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -409,8 +409,8 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
ASSERT(!structure->IsForeign());
// api style callbacks.
if (structure->IsAccessorInfo()) {
- Handle<AccessorInfo> accessor_info = Handle<AccessorInfo>::cast(structure);
- if (!accessor_info->IsCompatibleReceiver(*receiver)) {
+ Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
+ if (!info->IsCompatibleReceiver(*receiver)) {
Handle<Object> args[2] = { name, receiver };
Handle<Object> error =
isolate->factory()->NewTypeError("incompatible_method_receiver",
@@ -462,6 +462,17 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
}
+bool AccessorInfo::IsCompatibleReceiverType(Isolate* isolate,
Igor Sheludko 2014/07/30 10:37:44 What about making it instance method?
+ Handle<AccessorInfo> info,
+ Handle<HeapType> type) {
+ if (!info->HasExpectedReceiverType()) return true;
+ Handle<Map> map = IC::TypeToMap(*type, isolate);
+ if (!map->IsJSObjectMap()) return false;
+ return FunctionTemplateInfo::cast(info->expected_receiver_type())
+ ->IsTemplateFor(*map);
+}
+
+
MaybeHandle<Object> Object::SetPropertyWithAccessor(
Handle<Object> receiver, Handle<Name> name, Handle<Object> value,
Handle<JSObject> holder, Handle<Object> structure, StrictMode strict_mode) {
@@ -474,8 +485,8 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
// Don't call executable accessor setters with non-JSObject receivers.
if (!receiver->IsJSObject()) return value;
// api style callbacks
- ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(*structure);
- if (!data->IsCompatibleReceiver(*receiver)) {
+ ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure);
+ if (!info->IsCompatibleReceiver(*receiver)) {
Handle<Object> args[2] = { name, receiver };
Handle<Object> error =
isolate->factory()->NewTypeError("incompatible_method_receiver",
@@ -485,13 +496,13 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
}
// TODO(rossberg): Support symbols in the API.
if (name->IsSymbol()) return value;
- Object* call_obj = data->setter();
+ Object* call_obj = info->setter();
v8::AccessorSetterCallback call_fun =
v8::ToCData<v8::AccessorSetterCallback>(call_obj);
if (call_fun == NULL) return value;
Handle<String> key = Handle<String>::cast(name);
LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name));
- PropertyCallbackArguments args(isolate, data->data(), *receiver, *holder);
+ PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder);
args.Call(call_fun,
v8::Utils::ToLocal(key),
v8::Utils::ToLocal(value));
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698