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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 | 1235 |
1236 // Throw a reference error. | 1236 // Throw a reference error. |
1237 Handle<Name> name_handle(name); | 1237 Handle<Name> name_handle(name); |
1238 Handle<Object> error = | 1238 Handle<Object> error = |
1239 isolate->factory()->NewReferenceError("not_defined", | 1239 isolate->factory()->NewReferenceError("not_defined", |
1240 HandleVector(&name_handle, 1)); | 1240 HandleVector(&name_handle, 1)); |
1241 return isolate->Throw(*error); | 1241 return isolate->Throw(*error); |
1242 } | 1242 } |
1243 | 1243 |
1244 | 1244 |
1245 static MaybeObject* LoadWithInterceptor(Arguments* args, | 1245 static Handle<Object> LoadWithInterceptor(Arguments* args, |
1246 PropertyAttributes* attrs) { | 1246 PropertyAttributes* attrs) { |
1247 ASSERT(args->length() == StubCache::kInterceptorArgsLength); | 1247 ASSERT(args->length() == StubCache::kInterceptorArgsLength); |
1248 Handle<Name> name_handle = | 1248 Handle<Name> name_handle = |
1249 args->at<Name>(StubCache::kInterceptorArgsNameIndex); | 1249 args->at<Name>(StubCache::kInterceptorArgsNameIndex); |
1250 Handle<InterceptorInfo> interceptor_info = | 1250 Handle<InterceptorInfo> interceptor_info = |
1251 args->at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); | 1251 args->at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); |
1252 Handle<JSObject> receiver_handle = | 1252 Handle<JSObject> receiver_handle = |
1253 args->at<JSObject>(StubCache::kInterceptorArgsThisIndex); | 1253 args->at<JSObject>(StubCache::kInterceptorArgsThisIndex); |
1254 Handle<JSObject> holder_handle = | 1254 Handle<JSObject> holder_handle = |
1255 args->at<JSObject>(StubCache::kInterceptorArgsHolderIndex); | 1255 args->at<JSObject>(StubCache::kInterceptorArgsHolderIndex); |
1256 | 1256 |
1257 Isolate* isolate = receiver_handle->GetIsolate(); | 1257 Isolate* isolate = receiver_handle->GetIsolate(); |
1258 | 1258 |
1259 // TODO(rossberg): Support symbols in the API. | 1259 // TODO(rossberg): Support symbols in the API. |
1260 if (name_handle->IsSymbol()) | 1260 if (name_handle->IsSymbol()) { |
1261 return holder_handle->GetPropertyPostInterceptor( | 1261 return JSObject::GetPropertyPostInterceptor( |
1262 *receiver_handle, *name_handle, attrs); | 1262 holder_handle, receiver_handle, name_handle, attrs); |
1263 } | |
1263 Handle<String> name = Handle<String>::cast(name_handle); | 1264 Handle<String> name = Handle<String>::cast(name_handle); |
1264 | 1265 |
1265 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1266 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
1266 v8::NamedPropertyGetterCallback getter = | 1267 v8::NamedPropertyGetterCallback getter = |
1267 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); | 1268 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); |
1268 ASSERT(getter != NULL); | 1269 ASSERT(getter != NULL); |
1269 | 1270 |
1270 PropertyCallbackArguments callback_args(isolate, | 1271 PropertyCallbackArguments callback_args(isolate, |
1271 interceptor_info->data(), | 1272 interceptor_info->data(), |
1272 *receiver_handle, | 1273 *receiver_handle, |
1273 *holder_handle); | 1274 *holder_handle); |
1274 { | 1275 { |
1275 // Use the interceptor getter. | 1276 // Use the interceptor getter. |
1276 HandleScope scope(isolate); | |
1277 v8::Handle<v8::Value> r = | 1277 v8::Handle<v8::Value> r = |
1278 callback_args.Call(getter, v8::Utils::ToLocal(name)); | 1278 callback_args.Call(getter, v8::Utils::ToLocal(name)); |
1279 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1279 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
1280 if (!r.IsEmpty()) { | 1280 if (!r.IsEmpty()) { |
1281 *attrs = NONE; | 1281 *attrs = NONE; |
1282 Handle<Object> result = v8::Utils::OpenHandle(*r); | 1282 Handle<Object> result = v8::Utils::OpenHandle(*r); |
1283 result->VerifyApiCallResultType(); | 1283 result->VerifyApiCallResultType(); |
1284 return *result; | 1284 // Rebox handle to escape this scope. |
1285 return handle(*result, isolate); | |
Michael Starzinger
2013/10/02 18:56:24
I would keep the surrounding handle scope in line
| |
1285 } | 1286 } |
1286 } | 1287 } |
1287 | 1288 |
1288 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 1289 Handle<Object> result = JSObject::GetPropertyPostInterceptor( |
1289 *receiver_handle, | 1290 holder_handle, receiver_handle, name_handle, attrs); |
1290 *name_handle, | |
1291 attrs); | |
1292 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | |
1293 return result; | 1291 return result; |
1294 } | 1292 } |
1295 | 1293 |
1296 | 1294 |
1297 /** | 1295 /** |
1298 * Loads a property with an interceptor performing post interceptor | 1296 * Loads a property with an interceptor performing post interceptor |
1299 * lookup if interceptor failed. | 1297 * lookup if interceptor failed. |
1300 */ | 1298 */ |
1301 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) { | 1299 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) { |
1302 PropertyAttributes attr = NONE; | 1300 PropertyAttributes attr = NONE; |
1303 Object* result; | 1301 HandleScope scope(isolate); |
1304 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr); | 1302 Handle<Object> result = LoadWithInterceptor(&args, &attr); |
1305 if (!maybe_result->ToObject(&result)) return maybe_result; | 1303 RETURN_IF_EMPTY_HANDLE(isolate, result); |
1306 } | |
1307 | 1304 |
1308 // If the property is present, return it. | 1305 // If the property is present, return it. |
1309 if (attr != ABSENT) return result; | 1306 if (attr != ABSENT) return *result; |
1310 return ThrowReferenceError(isolate, Name::cast(args[0])); | 1307 return ThrowReferenceError(isolate, Name::cast(args[0])); |
1311 } | 1308 } |
1312 | 1309 |
1313 | 1310 |
1314 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) { | 1311 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) { |
1315 PropertyAttributes attr; | 1312 PropertyAttributes attr; |
1316 MaybeObject* result = LoadWithInterceptor(&args, &attr); | 1313 HandleScope scope(isolate); |
1317 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1314 Handle<Object> result = LoadWithInterceptor(&args, &attr); |
1315 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
1318 // This is call IC. In this case, we simply return the undefined result which | 1316 // This is call IC. In this case, we simply return the undefined result which |
1319 // will lead to an exception when trying to invoke the result as a | 1317 // will lead to an exception when trying to invoke the result as a |
1320 // function. | 1318 // function. |
1321 return result; | 1319 return *result; |
1322 } | 1320 } |
1323 | 1321 |
1324 | 1322 |
1325 RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) { | 1323 RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) { |
1326 HandleScope scope(isolate); | 1324 HandleScope scope(isolate); |
1327 ASSERT(args.length() == 4); | 1325 ASSERT(args.length() == 4); |
1328 Handle<JSObject> recv(JSObject::cast(args[0])); | 1326 Handle<JSObject> recv(JSObject::cast(args[0])); |
1329 Handle<Name> name(Name::cast(args[1])); | 1327 Handle<Name> name(Name::cast(args[1])); |
1330 Handle<Object> value(args[2], isolate); | 1328 Handle<Object> value(args[2], isolate); |
1331 ASSERT(args.smi_at(3) == kStrictMode || args.smi_at(3) == kNonStrictMode); | 1329 ASSERT(args.smi_at(3) == kStrictMode || args.smi_at(3) == kNonStrictMode); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2168 Handle<FunctionTemplateInfo>( | 2166 Handle<FunctionTemplateInfo>( |
2169 FunctionTemplateInfo::cast(signature->receiver())); | 2167 FunctionTemplateInfo::cast(signature->receiver())); |
2170 } | 2168 } |
2171 } | 2169 } |
2172 | 2170 |
2173 is_simple_api_call_ = true; | 2171 is_simple_api_call_ = true; |
2174 } | 2172 } |
2175 | 2173 |
2176 | 2174 |
2177 } } // namespace v8::internal | 2175 } } // namespace v8::internal |
OLD | NEW |