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