OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 ASSERT(callback->IsCompatibleReceiver(recv)); | 1097 ASSERT(callback->IsCompatibleReceiver(recv)); |
1098 Handle<Name> name = args.at<Name>(2); | 1098 Handle<Name> name = args.at<Name>(2); |
1099 Handle<Object> value = args.at<Object>(3); | 1099 Handle<Object> value = args.at<Object>(3); |
1100 HandleScope scope(isolate); | 1100 HandleScope scope(isolate); |
1101 | 1101 |
1102 // TODO(rossberg): Support symbols in the API. | 1102 // TODO(rossberg): Support symbols in the API. |
1103 if (name->IsSymbol()) return *value; | 1103 if (name->IsSymbol()) return *value; |
1104 Handle<String> str = Handle<String>::cast(name); | 1104 Handle<String> str = Handle<String>::cast(name); |
1105 | 1105 |
1106 LOG(isolate, ApiNamedPropertyAccess("store", recv, *name)); | 1106 LOG(isolate, ApiNamedPropertyAccess("store", recv, *name)); |
1107 CustomArguments custom_args(isolate, callback->data(), recv, recv); | 1107 PropertyCallbackArguments |
1108 v8::AccessorInfo info(custom_args.end()); | 1108 custom_args(isolate, callback->data(), recv, recv); |
1109 { | 1109 { |
1110 // Leaving JavaScript. | 1110 // Leaving JavaScript. |
1111 VMState<EXTERNAL> state(isolate); | 1111 VMState<EXTERNAL> state(isolate); |
1112 ExternalCallbackScope call_scope(isolate, setter_address); | 1112 ExternalCallbackScope call_scope(isolate, setter_address); |
1113 fun(v8::Utils::ToLocal(str), v8::Utils::ToLocal(value), info); | 1113 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); |
1114 } | 1114 } |
1115 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1115 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1116 return *value; | 1116 return *value; |
1117 } | 1117 } |
1118 | 1118 |
1119 | 1119 |
1120 static const int kAccessorInfoOffsetInInterceptorArgs = 2; | 1120 static const int kAccessorInfoOffsetInInterceptorArgs = 2; |
1121 | 1121 |
1122 | 1122 |
1123 /** | 1123 /** |
1124 * Attempts to load a property with an interceptor (which must be present), | 1124 * Attempts to load a property with an interceptor (which must be present), |
1125 * but doesn't search the prototype chain. | 1125 * but doesn't search the prototype chain. |
1126 * | 1126 * |
1127 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't | 1127 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't |
1128 * provide any value for the given name. | 1128 * provide any value for the given name. |
1129 */ | 1129 */ |
1130 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { | 1130 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
| 1131 typedef PropertyCallbackArguments PCA; |
| 1132 static const int kArgsOffset = kAccessorInfoOffsetInInterceptorArgs; |
1131 Handle<Name> name_handle = args.at<Name>(0); | 1133 Handle<Name> name_handle = args.at<Name>(0); |
1132 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); | 1134 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); |
1133 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); | 1135 ASSERT(kArgsOffset == 2); |
1134 ASSERT(args[2]->IsJSObject()); // Receiver. | 1136 // No ReturnValue in interceptors. |
1135 ASSERT(args[3]->IsJSObject()); // Holder. | 1137 ASSERT(args.length() == kArgsOffset + PCA::kArgsLength - 1); |
1136 ASSERT(args[5]->IsSmi()); // Isolate. | |
1137 ASSERT(args.length() == 6); | |
1138 | 1138 |
1139 // TODO(rossberg): Support symbols in the API. | 1139 // TODO(rossberg): Support symbols in the API. |
1140 if (name_handle->IsSymbol()) | 1140 if (name_handle->IsSymbol()) |
1141 return isolate->heap()->no_interceptor_result_sentinel(); | 1141 return isolate->heap()->no_interceptor_result_sentinel(); |
1142 Handle<String> name = Handle<String>::cast(name_handle); | 1142 Handle<String> name = Handle<String>::cast(name_handle); |
1143 | 1143 |
1144 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1144 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
1145 v8::NamedPropertyGetter getter = | 1145 v8::NamedPropertyGetter getter = |
1146 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); | 1146 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
1147 ASSERT(getter != NULL); | 1147 ASSERT(getter != NULL); |
1148 | 1148 |
| 1149 Handle<JSObject> receiver = |
| 1150 args.at<JSObject>(kArgsOffset - PCA::kThisIndex); |
| 1151 Handle<JSObject> holder = |
| 1152 args.at<JSObject>(kArgsOffset - PCA::kHolderIndex); |
| 1153 PropertyCallbackArguments callback_args(isolate, |
| 1154 interceptor_info->data(), |
| 1155 *receiver, |
| 1156 *holder); |
1149 { | 1157 { |
1150 // Use the interceptor getter. | 1158 // Use the interceptor getter. |
1151 v8::AccessorInfo info(args.arguments() - | |
1152 kAccessorInfoOffsetInInterceptorArgs); | |
1153 HandleScope scope(isolate); | 1159 HandleScope scope(isolate); |
1154 v8::Handle<v8::Value> r; | 1160 v8::Handle<v8::Value> r; |
1155 { | 1161 { |
1156 // Leaving JavaScript. | 1162 // Leaving JavaScript. |
1157 VMState<EXTERNAL> state(isolate); | 1163 VMState<EXTERNAL> state(isolate); |
1158 r = getter(v8::Utils::ToLocal(name), info); | 1164 r = callback_args.Call(getter, v8::Utils::ToLocal(name)); |
1159 } | 1165 } |
1160 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1166 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1161 if (!r.IsEmpty()) { | 1167 if (!r.IsEmpty()) { |
1162 Handle<Object> result = v8::Utils::OpenHandle(*r); | 1168 Handle<Object> result = v8::Utils::OpenHandle(*r); |
1163 result->VerifyApiCallResultType(); | 1169 result->VerifyApiCallResultType(); |
1164 return *v8::Utils::OpenHandle(*r); | 1170 return *v8::Utils::OpenHandle(*r); |
1165 } | 1171 } |
1166 } | 1172 } |
1167 | 1173 |
1168 return isolate->heap()->no_interceptor_result_sentinel(); | 1174 return isolate->heap()->no_interceptor_result_sentinel(); |
(...skipping 13 matching lines...) Expand all Loading... |
1182 Handle<Name> name_handle(name); | 1188 Handle<Name> name_handle(name); |
1183 Handle<Object> error = | 1189 Handle<Object> error = |
1184 FACTORY->NewReferenceError("not_defined", | 1190 FACTORY->NewReferenceError("not_defined", |
1185 HandleVector(&name_handle, 1)); | 1191 HandleVector(&name_handle, 1)); |
1186 return isolate->Throw(*error); | 1192 return isolate->Throw(*error); |
1187 } | 1193 } |
1188 | 1194 |
1189 | 1195 |
1190 static MaybeObject* LoadWithInterceptor(Arguments* args, | 1196 static MaybeObject* LoadWithInterceptor(Arguments* args, |
1191 PropertyAttributes* attrs) { | 1197 PropertyAttributes* attrs) { |
| 1198 typedef PropertyCallbackArguments PCA; |
| 1199 static const int kArgsOffset = kAccessorInfoOffsetInInterceptorArgs; |
1192 Handle<Name> name_handle = args->at<Name>(0); | 1200 Handle<Name> name_handle = args->at<Name>(0); |
1193 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); | 1201 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); |
1194 ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2); | 1202 ASSERT(kArgsOffset == 2); |
1195 Handle<JSObject> receiver_handle = args->at<JSObject>(2); | 1203 // No ReturnValue in interceptors. |
1196 Handle<JSObject> holder_handle = args->at<JSObject>(3); | 1204 ASSERT(args->length() == kArgsOffset + PCA::kArgsLength - 1); |
1197 ASSERT(args->length() == 6); | 1205 Handle<JSObject> receiver_handle = |
| 1206 args->at<JSObject>(kArgsOffset - PCA::kThisIndex); |
| 1207 Handle<JSObject> holder_handle = |
| 1208 args->at<JSObject>(kArgsOffset - PCA::kHolderIndex); |
1198 | 1209 |
1199 Isolate* isolate = receiver_handle->GetIsolate(); | 1210 Isolate* isolate = receiver_handle->GetIsolate(); |
1200 | 1211 |
1201 // TODO(rossberg): Support symbols in the API. | 1212 // TODO(rossberg): Support symbols in the API. |
1202 if (name_handle->IsSymbol()) | 1213 if (name_handle->IsSymbol()) |
1203 return holder_handle->GetPropertyPostInterceptor( | 1214 return holder_handle->GetPropertyPostInterceptor( |
1204 *receiver_handle, *name_handle, attrs); | 1215 *receiver_handle, *name_handle, attrs); |
1205 Handle<String> name = Handle<String>::cast(name_handle); | 1216 Handle<String> name = Handle<String>::cast(name_handle); |
1206 | 1217 |
1207 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1218 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
1208 v8::NamedPropertyGetter getter = | 1219 v8::NamedPropertyGetter getter = |
1209 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); | 1220 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
1210 ASSERT(getter != NULL); | 1221 ASSERT(getter != NULL); |
1211 | 1222 |
| 1223 PropertyCallbackArguments callback_args(isolate, |
| 1224 interceptor_info->data(), |
| 1225 *receiver_handle, |
| 1226 *holder_handle); |
1212 { | 1227 { |
1213 // Use the interceptor getter. | 1228 // Use the interceptor getter. |
1214 v8::AccessorInfo info(args->arguments() - | |
1215 kAccessorInfoOffsetInInterceptorArgs); | |
1216 HandleScope scope(isolate); | 1229 HandleScope scope(isolate); |
1217 v8::Handle<v8::Value> r; | 1230 v8::Handle<v8::Value> r; |
1218 { | 1231 { |
1219 // Leaving JavaScript. | 1232 // Leaving JavaScript. |
1220 VMState<EXTERNAL> state(isolate); | 1233 VMState<EXTERNAL> state(isolate); |
1221 r = getter(v8::Utils::ToLocal(name), info); | 1234 r = callback_args.Call(getter, v8::Utils::ToLocal(name)); |
1222 } | 1235 } |
1223 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1236 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1224 if (!r.IsEmpty()) { | 1237 if (!r.IsEmpty()) { |
1225 *attrs = NONE; | 1238 *attrs = NONE; |
1226 Handle<Object> result = v8::Utils::OpenHandle(*r); | 1239 Handle<Object> result = v8::Utils::OpenHandle(*r); |
1227 result->VerifyApiCallResultType(); | 1240 result->VerifyApiCallResultType(); |
1228 return *result; | 1241 return *result; |
1229 } | 1242 } |
1230 } | 1243 } |
1231 | 1244 |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 Handle<FunctionTemplateInfo>( | 2100 Handle<FunctionTemplateInfo>( |
2088 FunctionTemplateInfo::cast(signature->receiver())); | 2101 FunctionTemplateInfo::cast(signature->receiver())); |
2089 } | 2102 } |
2090 } | 2103 } |
2091 | 2104 |
2092 is_simple_api_call_ = true; | 2105 is_simple_api_call_ = true; |
2093 } | 2106 } |
2094 | 2107 |
2095 | 2108 |
2096 } } // namespace v8::internal | 2109 } } // namespace v8::internal |
OLD | NEW |