| 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 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 | 1242 |
| 1243 LOG(isolate, ApiNamedPropertyAccess("store", recv, *name)); | 1243 LOG(isolate, ApiNamedPropertyAccess("store", recv, *name)); |
| 1244 PropertyCallbackArguments | 1244 PropertyCallbackArguments |
| 1245 custom_args(isolate, callback->data(), recv, recv); | 1245 custom_args(isolate, callback->data(), recv, recv); |
| 1246 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); | 1246 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); |
| 1247 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1247 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1248 return *value; | 1248 return *value; |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 | 1251 |
| 1252 static const int kAccessorInfoOffsetInInterceptorArgs = 2; |
| 1253 |
| 1254 |
| 1252 /** | 1255 /** |
| 1253 * Attempts to load a property with an interceptor (which must be present), | 1256 * Attempts to load a property with an interceptor (which must be present), |
| 1254 * but doesn't search the prototype chain. | 1257 * but doesn't search the prototype chain. |
| 1255 * | 1258 * |
| 1256 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't | 1259 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't |
| 1257 * provide any value for the given name. | 1260 * provide any value for the given name. |
| 1258 */ | 1261 */ |
| 1259 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { | 1262 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) { |
| 1260 ASSERT(args.length() == StubCache::kInterceptorArgsLength); | 1263 typedef PropertyCallbackArguments PCA; |
| 1261 Handle<Name> name_handle = | 1264 static const int kArgsOffset = kAccessorInfoOffsetInInterceptorArgs; |
| 1262 args.at<Name>(StubCache::kInterceptorArgsNameIndex); | 1265 Handle<Name> name_handle = args.at<Name>(0); |
| 1263 Handle<InterceptorInfo> interceptor_info = | 1266 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1); |
| 1264 args.at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); | 1267 ASSERT(kArgsOffset == 2); |
| 1268 // No ReturnValue in interceptors. |
| 1269 ASSERT_EQ(kArgsOffset + PCA::kArgsLength - 2, args.length()); |
| 1265 | 1270 |
| 1266 // TODO(rossberg): Support symbols in the API. | 1271 // TODO(rossberg): Support symbols in the API. |
| 1267 if (name_handle->IsSymbol()) | 1272 if (name_handle->IsSymbol()) |
| 1268 return isolate->heap()->no_interceptor_result_sentinel(); | 1273 return isolate->heap()->no_interceptor_result_sentinel(); |
| 1269 Handle<String> name = Handle<String>::cast(name_handle); | 1274 Handle<String> name = Handle<String>::cast(name_handle); |
| 1270 | 1275 |
| 1271 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1276 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
| 1272 v8::NamedPropertyGetterCallback getter = | 1277 v8::NamedPropertyGetterCallback getter = |
| 1273 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); | 1278 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); |
| 1274 ASSERT(getter != NULL); | 1279 ASSERT(getter != NULL); |
| 1275 | 1280 |
| 1276 Handle<JSObject> receiver = | 1281 Handle<JSObject> receiver = |
| 1277 args.at<JSObject>(StubCache::kInterceptorArgsThisIndex); | 1282 args.at<JSObject>(kArgsOffset - PCA::kThisIndex); |
| 1278 Handle<JSObject> holder = | 1283 Handle<JSObject> holder = |
| 1279 args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex); | 1284 args.at<JSObject>(kArgsOffset - PCA::kHolderIndex); |
| 1280 PropertyCallbackArguments callback_args( | 1285 PropertyCallbackArguments callback_args(isolate, |
| 1281 isolate, interceptor_info->data(), *receiver, *holder); | 1286 interceptor_info->data(), |
| 1287 *receiver, |
| 1288 *holder); |
| 1282 { | 1289 { |
| 1283 // Use the interceptor getter. | 1290 // Use the interceptor getter. |
| 1284 HandleScope scope(isolate); | 1291 HandleScope scope(isolate); |
| 1285 v8::Handle<v8::Value> r = | 1292 v8::Handle<v8::Value> r = |
| 1286 callback_args.Call(getter, v8::Utils::ToLocal(name)); | 1293 callback_args.Call(getter, v8::Utils::ToLocal(name)); |
| 1287 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1294 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1288 if (!r.IsEmpty()) { | 1295 if (!r.IsEmpty()) { |
| 1289 Handle<Object> result = v8::Utils::OpenHandle(*r); | 1296 Handle<Object> result = v8::Utils::OpenHandle(*r); |
| 1290 result->VerifyApiCallResultType(); | 1297 result->VerifyApiCallResultType(); |
| 1291 return *v8::Utils::OpenHandle(*r); | 1298 return *v8::Utils::OpenHandle(*r); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1309 Handle<Name> name_handle(name); | 1316 Handle<Name> name_handle(name); |
| 1310 Handle<Object> error = | 1317 Handle<Object> error = |
| 1311 isolate->factory()->NewReferenceError("not_defined", | 1318 isolate->factory()->NewReferenceError("not_defined", |
| 1312 HandleVector(&name_handle, 1)); | 1319 HandleVector(&name_handle, 1)); |
| 1313 return isolate->Throw(*error); | 1320 return isolate->Throw(*error); |
| 1314 } | 1321 } |
| 1315 | 1322 |
| 1316 | 1323 |
| 1317 static MaybeObject* LoadWithInterceptor(Arguments* args, | 1324 static MaybeObject* LoadWithInterceptor(Arguments* args, |
| 1318 PropertyAttributes* attrs) { | 1325 PropertyAttributes* attrs) { |
| 1319 ASSERT(args->length() == StubCache::kInterceptorArgsLength); | 1326 typedef PropertyCallbackArguments PCA; |
| 1320 Handle<Name> name_handle = | 1327 static const int kArgsOffset = kAccessorInfoOffsetInInterceptorArgs; |
| 1321 args->at<Name>(StubCache::kInterceptorArgsNameIndex); | 1328 Handle<Name> name_handle = args->at<Name>(0); |
| 1322 Handle<InterceptorInfo> interceptor_info = | 1329 Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1); |
| 1323 args->at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); | 1330 ASSERT(kArgsOffset == 2); |
| 1331 // No ReturnValue in interceptors. |
| 1332 ASSERT_EQ(kArgsOffset + PCA::kArgsLength - 2, args->length()); |
| 1324 Handle<JSObject> receiver_handle = | 1333 Handle<JSObject> receiver_handle = |
| 1325 args->at<JSObject>(StubCache::kInterceptorArgsThisIndex); | 1334 args->at<JSObject>(kArgsOffset - PCA::kThisIndex); |
| 1326 Handle<JSObject> holder_handle = | 1335 Handle<JSObject> holder_handle = |
| 1327 args->at<JSObject>(StubCache::kInterceptorArgsHolderIndex); | 1336 args->at<JSObject>(kArgsOffset - PCA::kHolderIndex); |
| 1328 | 1337 |
| 1329 Isolate* isolate = receiver_handle->GetIsolate(); | 1338 Isolate* isolate = receiver_handle->GetIsolate(); |
| 1330 | 1339 |
| 1331 // TODO(rossberg): Support symbols in the API. | 1340 // TODO(rossberg): Support symbols in the API. |
| 1332 if (name_handle->IsSymbol()) | 1341 if (name_handle->IsSymbol()) |
| 1333 return holder_handle->GetPropertyPostInterceptor( | 1342 return holder_handle->GetPropertyPostInterceptor( |
| 1334 *receiver_handle, *name_handle, attrs); | 1343 *receiver_handle, *name_handle, attrs); |
| 1335 Handle<String> name = Handle<String>::cast(name_handle); | 1344 Handle<String> name = Handle<String>::cast(name_handle); |
| 1336 | 1345 |
| 1337 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1346 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2252 Handle<FunctionTemplateInfo>( | 2261 Handle<FunctionTemplateInfo>( |
| 2253 FunctionTemplateInfo::cast(signature->receiver())); | 2262 FunctionTemplateInfo::cast(signature->receiver())); |
| 2254 } | 2263 } |
| 2255 } | 2264 } |
| 2256 | 2265 |
| 2257 is_simple_api_call_ = true; | 2266 is_simple_api_call_ = true; |
| 2258 } | 2267 } |
| 2259 | 2268 |
| 2260 | 2269 |
| 2261 } } // namespace v8::internal | 2270 } } // namespace v8::internal |
| OLD | NEW |