OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 HandleScope scope(isolate); | 954 HandleScope scope(isolate); |
955 v8::Handle<v8::Value> result; | 955 v8::Handle<v8::Value> result; |
956 { | 956 { |
957 // Leaving JavaScript. | 957 // Leaving JavaScript. |
958 VMState state(isolate, EXTERNAL); | 958 VMState state(isolate, EXTERNAL); |
959 #ifdef ENABLE_LOGGING_AND_PROFILING | 959 #ifdef ENABLE_LOGGING_AND_PROFILING |
960 state.set_external_callback(getter_address); | 960 state.set_external_callback(getter_address); |
961 #endif | 961 #endif |
962 result = fun(v8::Utils::ToLocal(args.at<String>(4)), info); | 962 result = fun(v8::Utils::ToLocal(args.at<String>(4)), info); |
963 } | 963 } |
964 RETURN_IF_SCHEDULED_EXCEPTION(); | 964 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
965 if (result.IsEmpty()) return HEAP->undefined_value(); | 965 if (result.IsEmpty()) return HEAP->undefined_value(); |
966 return *v8::Utils::OpenHandle(*result); | 966 return *v8::Utils::OpenHandle(*result); |
967 } | 967 } |
968 | 968 |
969 | 969 |
970 MaybeObject* StoreCallbackProperty(RUNTIME_CALLING_CONVENTION) { | 970 MaybeObject* StoreCallbackProperty(RUNTIME_CALLING_CONVENTION) { |
971 RUNTIME_GET_ISOLATE; | 971 RUNTIME_GET_ISOLATE; |
972 JSObject* recv = JSObject::cast(args[0]); | 972 JSObject* recv = JSObject::cast(args[0]); |
973 AccessorInfo* callback = AccessorInfo::cast(args[1]); | 973 AccessorInfo* callback = AccessorInfo::cast(args[1]); |
974 Address setter_address = v8::ToCData<Address>(callback->setter()); | 974 Address setter_address = v8::ToCData<Address>(callback->setter()); |
975 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); | 975 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); |
976 ASSERT(fun != NULL); | 976 ASSERT(fun != NULL); |
977 Handle<String> name = args.at<String>(2); | 977 Handle<String> name = args.at<String>(2); |
978 Handle<Object> value = args.at<Object>(3); | 978 Handle<Object> value = args.at<Object>(3); |
979 HandleScope scope(isolate); | 979 HandleScope scope(isolate); |
980 LOG(ApiNamedPropertyAccess("store", recv, *name)); | 980 LOG(ApiNamedPropertyAccess("store", recv, *name)); |
981 CustomArguments custom_args(isolate, callback->data(), recv, recv); | 981 CustomArguments custom_args(isolate, callback->data(), recv, recv); |
982 v8::AccessorInfo info(custom_args.end()); | 982 v8::AccessorInfo info(custom_args.end()); |
983 { | 983 { |
984 // Leaving JavaScript. | 984 // Leaving JavaScript. |
985 VMState state(isolate, EXTERNAL); | 985 VMState state(isolate, EXTERNAL); |
986 #ifdef ENABLE_LOGGING_AND_PROFILING | 986 #ifdef ENABLE_LOGGING_AND_PROFILING |
987 state.set_external_callback(setter_address); | 987 state.set_external_callback(setter_address); |
988 #endif | 988 #endif |
989 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 989 fun(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
990 } | 990 } |
991 RETURN_IF_SCHEDULED_EXCEPTION(); | 991 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
992 return *value; | 992 return *value; |
993 } | 993 } |
994 | 994 |
995 | 995 |
996 static const int kAccessorInfoOffsetInInterceptorArgs = 2; | 996 static const int kAccessorInfoOffsetInInterceptorArgs = 2; |
997 | 997 |
998 | 998 |
999 /** | 999 /** |
1000 * Attempts to load a property with an interceptor (which must be present), | 1000 * Attempts to load a property with an interceptor (which must be present), |
1001 * but doesn't search the prototype chain. | 1001 * but doesn't search the prototype chain. |
(...skipping 12 matching lines...) Expand all Loading... |
1014 | 1014 |
1015 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 1015 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
1016 v8::NamedPropertyGetter getter = | 1016 v8::NamedPropertyGetter getter = |
1017 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); | 1017 FUNCTION_CAST<v8::NamedPropertyGetter>(getter_address); |
1018 ASSERT(getter != NULL); | 1018 ASSERT(getter != NULL); |
1019 | 1019 |
1020 { | 1020 { |
1021 // Use the interceptor getter. | 1021 // Use the interceptor getter. |
1022 v8::AccessorInfo info(args.arguments() - | 1022 v8::AccessorInfo info(args.arguments() - |
1023 kAccessorInfoOffsetInInterceptorArgs); | 1023 kAccessorInfoOffsetInInterceptorArgs); |
1024 HandleScope scope; | 1024 HandleScope scope(isolate); |
1025 v8::Handle<v8::Value> r; | 1025 v8::Handle<v8::Value> r; |
1026 { | 1026 { |
1027 // Leaving JavaScript. | 1027 // Leaving JavaScript. |
1028 VMState state(isolate, EXTERNAL); | 1028 VMState state(isolate, EXTERNAL); |
1029 r = getter(v8::Utils::ToLocal(name_handle), info); | 1029 r = getter(v8::Utils::ToLocal(name_handle), info); |
1030 } | 1030 } |
1031 RETURN_IF_SCHEDULED_EXCEPTION(); | 1031 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1032 if (!r.IsEmpty()) { | 1032 if (!r.IsEmpty()) { |
1033 return *v8::Utils::OpenHandle(*r); | 1033 return *v8::Utils::OpenHandle(*r); |
1034 } | 1034 } |
1035 } | 1035 } |
1036 | 1036 |
1037 return HEAP->no_interceptor_result_sentinel(); | 1037 return isolate->heap()->no_interceptor_result_sentinel(); |
1038 } | 1038 } |
1039 | 1039 |
1040 | 1040 |
1041 static MaybeObject* ThrowReferenceError(String* name) { | 1041 static MaybeObject* ThrowReferenceError(String* name) { |
1042 // If the load is non-contextual, just return the undefined result. | 1042 // If the load is non-contextual, just return the undefined result. |
1043 // Note that both keyed and non-keyed loads may end up here, so we | 1043 // Note that both keyed and non-keyed loads may end up here, so we |
1044 // can't use either LoadIC or KeyedLoadIC constructors. | 1044 // can't use either LoadIC or KeyedLoadIC constructors. |
1045 IC ic(IC::NO_EXTRA_FRAME, Isolate::Current()); | 1045 IC ic(IC::NO_EXTRA_FRAME, Isolate::Current()); |
1046 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub()); | 1046 ASSERT(ic.target()->is_load_stub() || ic.target()->is_keyed_load_stub()); |
1047 if (!ic.SlowIsContextual()) return HEAP->undefined_value(); | 1047 if (!ic.SlowIsContextual()) return HEAP->undefined_value(); |
(...skipping 28 matching lines...) Expand all Loading... |
1076 // Use the interceptor getter. | 1076 // Use the interceptor getter. |
1077 v8::AccessorInfo info(args->arguments() - | 1077 v8::AccessorInfo info(args->arguments() - |
1078 kAccessorInfoOffsetInInterceptorArgs); | 1078 kAccessorInfoOffsetInInterceptorArgs); |
1079 HandleScope scope(isolate); | 1079 HandleScope scope(isolate); |
1080 v8::Handle<v8::Value> r; | 1080 v8::Handle<v8::Value> r; |
1081 { | 1081 { |
1082 // Leaving JavaScript. | 1082 // Leaving JavaScript. |
1083 VMState state(isolate, EXTERNAL); | 1083 VMState state(isolate, EXTERNAL); |
1084 r = getter(v8::Utils::ToLocal(name_handle), info); | 1084 r = getter(v8::Utils::ToLocal(name_handle), info); |
1085 } | 1085 } |
1086 RETURN_IF_SCHEDULED_EXCEPTION(); | 1086 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1087 if (!r.IsEmpty()) { | 1087 if (!r.IsEmpty()) { |
1088 *attrs = NONE; | 1088 *attrs = NONE; |
1089 return *v8::Utils::OpenHandle(*r); | 1089 return *v8::Utils::OpenHandle(*r); |
1090 } | 1090 } |
1091 } | 1091 } |
1092 | 1092 |
1093 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 1093 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( |
1094 *receiver_handle, | 1094 *receiver_handle, |
1095 *name_handle, | 1095 *name_handle, |
1096 attrs); | 1096 attrs); |
1097 RETURN_IF_SCHEDULED_EXCEPTION(); | 1097 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1098 return result; | 1098 return result; |
1099 } | 1099 } |
1100 | 1100 |
1101 | 1101 |
1102 /** | 1102 /** |
1103 * Loads a property with an interceptor performing post interceptor | 1103 * Loads a property with an interceptor performing post interceptor |
1104 * lookup if interceptor failed. | 1104 * lookup if interceptor failed. |
1105 */ | 1105 */ |
1106 MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION) { | 1106 MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION) { |
1107 RUNTIME_GET_ISOLATE; | 1107 RUNTIME_GET_ISOLATE; |
1108 PropertyAttributes attr = NONE; | 1108 PropertyAttributes attr = NONE; |
1109 Object* result; | 1109 Object* result; |
1110 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr); | 1110 { MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr); |
1111 if (!maybe_result->ToObject(&result)) return maybe_result; | 1111 if (!maybe_result->ToObject(&result)) return maybe_result; |
1112 } | 1112 } |
1113 | 1113 |
1114 // If the property is present, return it. | 1114 // If the property is present, return it. |
1115 if (attr != ABSENT) return result; | 1115 if (attr != ABSENT) return result; |
1116 return ThrowReferenceError(String::cast(args[0])); | 1116 return ThrowReferenceError(String::cast(args[0])); |
1117 } | 1117 } |
1118 | 1118 |
1119 | 1119 |
1120 MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION) { | 1120 MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION) { |
1121 RUNTIME_GET_ISOLATE; | 1121 RUNTIME_GET_ISOLATE; |
1122 PropertyAttributes attr; | 1122 PropertyAttributes attr; |
1123 MaybeObject* result = LoadWithInterceptor(&args, &attr); | 1123 MaybeObject* result = LoadWithInterceptor(&args, &attr); |
1124 RETURN_IF_SCHEDULED_EXCEPTION(); | 1124 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1125 // This is call IC. In this case, we simply return the undefined result which | 1125 // This is call IC. In this case, we simply return the undefined result which |
1126 // will lead to an exception when trying to invoke the result as a | 1126 // will lead to an exception when trying to invoke the result as a |
1127 // function. | 1127 // function. |
1128 return result; | 1128 return result; |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
1132 MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION) { | 1132 MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION) { |
1133 RUNTIME_GET_ISOLATE; | 1133 RUNTIME_GET_ISOLATE; |
1134 JSObject* recv = JSObject::cast(args[0]); | 1134 JSObject* recv = JSObject::cast(args[0]); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 expected_receiver_type_ = | 1529 expected_receiver_type_ = |
1530 FunctionTemplateInfo::cast(signature->receiver()); | 1530 FunctionTemplateInfo::cast(signature->receiver()); |
1531 } | 1531 } |
1532 } | 1532 } |
1533 | 1533 |
1534 is_simple_api_call_ = true; | 1534 is_simple_api_call_ = true; |
1535 } | 1535 } |
1536 | 1536 |
1537 | 1537 |
1538 } } // namespace v8::internal | 1538 } } // namespace v8::internal |
OLD | NEW |