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