| 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 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1216 |
| 1217 // Throw a reference error. | 1217 // Throw a reference error. |
| 1218 Handle<Name> name_handle(name); | 1218 Handle<Name> name_handle(name); |
| 1219 Handle<Object> error = | 1219 Handle<Object> error = |
| 1220 isolate->factory()->NewReferenceError("not_defined", | 1220 isolate->factory()->NewReferenceError("not_defined", |
| 1221 HandleVector(&name_handle, 1)); | 1221 HandleVector(&name_handle, 1)); |
| 1222 return isolate->Throw(*error); | 1222 return isolate->Throw(*error); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 | 1225 |
| 1226 static MaybeObject* LoadWithInterceptor(Arguments* args, | 1226 static Handle<Object> LoadWithInterceptor(Arguments* args, |
| 1227 PropertyAttributes* attrs) { | 1227 PropertyAttributes* attrs) { |
| 1228 ASSERT(args->length() == StubCache::kInterceptorArgsLength); | 1228 ASSERT(args->length() == StubCache::kInterceptorArgsLength); |
| 1229 Handle<Name> name_handle = | 1229 Handle<Name> name_handle = |
| 1230 args->at<Name>(StubCache::kInterceptorArgsNameIndex); | 1230 args->at<Name>(StubCache::kInterceptorArgsNameIndex); |
| 1231 Handle<InterceptorInfo> interceptor_info = | 1231 Handle<InterceptorInfo> interceptor_info = |
| 1232 args->at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); | 1232 args->at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); |
| 1233 Handle<JSObject> receiver_handle = | 1233 Handle<JSObject> receiver_handle = |
| 1234 args->at<JSObject>(StubCache::kInterceptorArgsThisIndex); | 1234 args->at<JSObject>(StubCache::kInterceptorArgsThisIndex); |
| 1235 Handle<JSObject> holder_handle = | 1235 Handle<JSObject> holder_handle = |
| 1236 args->at<JSObject>(StubCache::kInterceptorArgsHolderIndex); | 1236 args->at<JSObject>(StubCache::kInterceptorArgsHolderIndex); |
| 1237 | 1237 |
| 1238 Isolate* isolate = receiver_handle->GetIsolate(); | 1238 Isolate* isolate = receiver_handle->GetIsolate(); |
| 1239 | 1239 |
| 1240 // TODO(rossberg): Support symbols in the API. | 1240 // TODO(rossberg): Support symbols in the API. |
| 1241 if (name_handle->IsSymbol()) | 1241 if (name_handle->IsSymbol()) { |
| 1242 return holder_handle->GetPropertyPostInterceptor( | 1242 return JSObject::GetPropertyPostInterceptor( |
| 1243 *receiver_handle, *name_handle, attrs); | 1243 holder_handle, receiver_handle, name_handle, attrs); |
| 1244 } |
| 1244 Handle<String> name = Handle<String>::cast(name_handle); | 1245 Handle<String> name = Handle<String>::cast(name_handle); |
| 1245 | 1246 |
| 1246 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1247 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
| 1247 v8::NamedPropertyGetterCallback getter = | 1248 v8::NamedPropertyGetterCallback getter = |
| 1248 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); | 1249 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); |
| 1249 ASSERT(getter != NULL); | 1250 ASSERT(getter != NULL); |
| 1250 | 1251 |
| 1251 PropertyCallbackArguments callback_args(isolate, | 1252 PropertyCallbackArguments callback_args(isolate, |
| 1252 interceptor_info->data(), | 1253 interceptor_info->data(), |
| 1253 *receiver_handle, | 1254 *receiver_handle, |
| 1254 *holder_handle); | 1255 *holder_handle); |
| 1255 { | 1256 { |
| 1257 HandleScope scope(isolate); |
| 1256 // Use the interceptor getter. | 1258 // Use the interceptor getter. |
| 1257 HandleScope scope(isolate); | |
| 1258 v8::Handle<v8::Value> r = | 1259 v8::Handle<v8::Value> r = |
| 1259 callback_args.Call(getter, v8::Utils::ToLocal(name)); | 1260 callback_args.Call(getter, v8::Utils::ToLocal(name)); |
| 1260 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1261 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1261 if (!r.IsEmpty()) { | 1262 if (!r.IsEmpty()) { |
| 1262 *attrs = NONE; | 1263 *attrs = NONE; |
| 1263 Handle<Object> result = v8::Utils::OpenHandle(*r); | 1264 Handle<Object> result = v8::Utils::OpenHandle(*r); |
| 1264 result->VerifyApiCallResultType(); | 1265 result->VerifyApiCallResultType(); |
| 1265 return *result; | 1266 return scope.CloseAndEscape(result); |
| 1266 } | 1267 } |
| 1267 } | 1268 } |
| 1268 | 1269 |
| 1269 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 1270 Handle<Object> result = JSObject::GetPropertyPostInterceptor( |
| 1270 *receiver_handle, | 1271 holder_handle, receiver_handle, name_handle, attrs); |
| 1271 *name_handle, | |
| 1272 attrs); | |
| 1273 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | |
| 1274 return result; | 1272 return result; |
| 1275 } | 1273 } |
| 1276 | 1274 |
| 1277 | 1275 |
| 1278 /** | 1276 /** |
| 1279 * Loads a property with an interceptor performing post interceptor | 1277 * Loads a property with an interceptor performing post interceptor |
| 1280 * lookup if interceptor failed. | 1278 * lookup if interceptor failed. |
| 1281 */ | 1279 */ |
| 1282 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) { | 1280 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) { |
| 1283 PropertyAttributes attr = NONE; | 1281 PropertyAttributes attr = NONE; |
| 1284 Object* result; | 1282 HandleScope scope(isolate); |
| 1285 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr); | 1283 Handle<Object> result = LoadWithInterceptor(&args, &attr); |
| 1286 if (!maybe_result->ToObject(&result)) return maybe_result; | 1284 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 1287 } | |
| 1288 | 1285 |
| 1289 // If the property is present, return it. | 1286 // If the property is present, return it. |
| 1290 if (attr != ABSENT) return result; | 1287 if (attr != ABSENT) return *result; |
| 1291 return ThrowReferenceError(isolate, Name::cast(args[0])); | 1288 return ThrowReferenceError(isolate, Name::cast(args[0])); |
| 1292 } | 1289 } |
| 1293 | 1290 |
| 1294 | 1291 |
| 1295 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) { | 1292 RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) { |
| 1296 PropertyAttributes attr; | 1293 PropertyAttributes attr; |
| 1297 MaybeObject* result = LoadWithInterceptor(&args, &attr); | 1294 HandleScope scope(isolate); |
| 1298 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1295 Handle<Object> result = LoadWithInterceptor(&args, &attr); |
| 1296 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 1299 // This is call IC. In this case, we simply return the undefined result which | 1297 // This is call IC. In this case, we simply return the undefined result which |
| 1300 // will lead to an exception when trying to invoke the result as a | 1298 // will lead to an exception when trying to invoke the result as a |
| 1301 // function. | 1299 // function. |
| 1302 return result; | 1300 return *result; |
| 1303 } | 1301 } |
| 1304 | 1302 |
| 1305 | 1303 |
| 1306 RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) { | 1304 RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) { |
| 1307 HandleScope scope(isolate); | 1305 HandleScope scope(isolate); |
| 1308 ASSERT(args.length() == 4); | 1306 ASSERT(args.length() == 4); |
| 1309 Handle<JSObject> recv(JSObject::cast(args[0])); | 1307 Handle<JSObject> recv(JSObject::cast(args[0])); |
| 1310 Handle<Name> name(Name::cast(args[1])); | 1308 Handle<Name> name(Name::cast(args[1])); |
| 1311 Handle<Object> value(args[2], isolate); | 1309 Handle<Object> value(args[2], isolate); |
| 1312 ASSERT(args.smi_at(3) == kStrictMode || args.smi_at(3) == kNonStrictMode); | 1310 ASSERT(args.smi_at(3) == kStrictMode || args.smi_at(3) == kNonStrictMode); |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 Handle<FunctionTemplateInfo>( | 2147 Handle<FunctionTemplateInfo>( |
| 2150 FunctionTemplateInfo::cast(signature->receiver())); | 2148 FunctionTemplateInfo::cast(signature->receiver())); |
| 2151 } | 2149 } |
| 2152 } | 2150 } |
| 2153 | 2151 |
| 2154 is_simple_api_call_ = true; | 2152 is_simple_api_call_ = true; |
| 2155 } | 2153 } |
| 2156 | 2154 |
| 2157 | 2155 |
| 2158 } } // namespace v8::internal | 2156 } } // namespace v8::internal |
| OLD | NEW |