| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 | 1007 |
| 1008 Object* raw_call_data = fun_data->call_code(); | 1008 Object* raw_call_data = fun_data->call_code(); |
| 1009 if (!raw_call_data->IsUndefined()) { | 1009 if (!raw_call_data->IsUndefined()) { |
| 1010 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1010 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
| 1011 Object* callback_obj = call_data->callback(); | 1011 Object* callback_obj = call_data->callback(); |
| 1012 v8::InvocationCallback callback = | 1012 v8::InvocationCallback callback = |
| 1013 v8::ToCData<v8::InvocationCallback>(callback_obj); | 1013 v8::ToCData<v8::InvocationCallback>(callback_obj); |
| 1014 Object* data_obj = call_data->data(); | 1014 Object* data_obj = call_data->data(); |
| 1015 Object* result; | 1015 Object* result; |
| 1016 | 1016 |
| 1017 Handle<Object> data_handle(data_obj); | 1017 LOG(ApiObjectAccess("call", JSObject::cast(*args.receiver()))); |
| 1018 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle); | |
| 1019 ASSERT(raw_holder->IsJSObject()); | 1018 ASSERT(raw_holder->IsJSObject()); |
| 1020 v8::Local<v8::Function> callee = v8::Utils::ToLocal(function); | 1019 |
| 1021 Handle<JSObject> holder_handle(JSObject::cast(raw_holder)); | 1020 CustomArguments custom; |
| 1022 v8::Local<v8::Object> holder = v8::Utils::ToLocal(holder_handle); | 1021 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), |
| 1023 LOG(ApiObjectAccess("call", JSObject::cast(*args.receiver()))); | 1022 data_obj, *function, raw_holder); |
| 1023 |
| 1024 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( | 1024 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( |
| 1025 data, | 1025 custom.end(), |
| 1026 holder, | 1026 &args[0] - 1, |
| 1027 callee, | 1027 args.length() - 1, |
| 1028 is_construct, | 1028 is_construct); |
| 1029 reinterpret_cast<void**>(&args[0] - 1), | |
| 1030 args.length() - 1); | |
| 1031 | 1029 |
| 1032 v8::Handle<v8::Value> value; | 1030 v8::Handle<v8::Value> value; |
| 1033 { | 1031 { |
| 1034 // Leaving JavaScript. | 1032 // Leaving JavaScript. |
| 1035 VMState state(EXTERNAL); | 1033 VMState state(EXTERNAL); |
| 1036 #ifdef ENABLE_LOGGING_AND_PROFILING | 1034 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 1037 state.set_external_callback(v8::ToCData<Address>(callback_obj)); | 1035 state.set_external_callback(v8::ToCData<Address>(callback_obj)); |
| 1038 #endif | 1036 #endif |
| 1039 value = callback(new_args); | 1037 value = callback(new_args); |
| 1040 } | 1038 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 BUILTIN(FastHandleApiCall) { | 1080 BUILTIN(FastHandleApiCall) { |
| 1083 ASSERT(!CalledAsConstructor()); | 1081 ASSERT(!CalledAsConstructor()); |
| 1084 const bool is_construct = false; | 1082 const bool is_construct = false; |
| 1085 | 1083 |
| 1086 // We expect four more arguments: function, callback, call data, and holder. | 1084 // We expect four more arguments: function, callback, call data, and holder. |
| 1087 const int args_length = args.length() - 4; | 1085 const int args_length = args.length() - 4; |
| 1088 ASSERT(args_length >= 0); | 1086 ASSERT(args_length >= 0); |
| 1089 | 1087 |
| 1090 Handle<JSFunction> function = args.at<JSFunction>(args_length); | 1088 Handle<JSFunction> function = args.at<JSFunction>(args_length); |
| 1091 Object* callback_obj = args[args_length + 1]; | 1089 Object* callback_obj = args[args_length + 1]; |
| 1092 Handle<Object> data_handle = args.at<Object>(args_length + 2); | 1090 Handle<Object> data = args.at<Object>(args_length + 2); |
| 1093 Handle<JSObject> checked_holder = args.at<JSObject>(args_length + 3); | 1091 Handle<JSObject> checked_holder = args.at<JSObject>(args_length + 3); |
| 1094 | 1092 |
| 1095 #ifdef DEBUG | 1093 #ifdef DEBUG |
| 1096 VerifyTypeCheck(checked_holder, function); | 1094 VerifyTypeCheck(checked_holder, function); |
| 1097 #endif | 1095 #endif |
| 1098 | 1096 |
| 1099 v8::Local<v8::Object> holder = v8::Utils::ToLocal(checked_holder); | 1097 CustomArguments custom; |
| 1100 v8::Local<v8::Function> callee = v8::Utils::ToLocal(function); | 1098 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), |
| 1101 v8::InvocationCallback callback = | 1099 *data, *function, *checked_holder); |
| 1102 v8::ToCData<v8::InvocationCallback>(callback_obj); | |
| 1103 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle); | |
| 1104 | 1100 |
| 1105 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( | 1101 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( |
| 1106 data, | 1102 custom.end(), |
| 1107 holder, | 1103 &args[0] - 1, |
| 1108 callee, | 1104 args_length - 1, |
| 1109 is_construct, | 1105 is_construct); |
| 1110 reinterpret_cast<void**>(&args[0] - 1), | |
| 1111 args_length - 1); | |
| 1112 | 1106 |
| 1113 HandleScope scope; | 1107 HandleScope scope; |
| 1114 Object* result; | 1108 Object* result; |
| 1115 v8::Handle<v8::Value> value; | 1109 v8::Handle<v8::Value> value; |
| 1116 { | 1110 { |
| 1117 // Leaving JavaScript. | 1111 // Leaving JavaScript. |
| 1118 VMState state(EXTERNAL); | 1112 VMState state(EXTERNAL); |
| 1119 #ifdef ENABLE_LOGGING_AND_PROFILING | 1113 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 1120 state.set_external_callback(v8::ToCData<Address>(callback_obj)); | 1114 state.set_external_callback(v8::ToCData<Address>(callback_obj)); |
| 1121 #endif | 1115 #endif |
| 1116 v8::InvocationCallback callback = |
| 1117 v8::ToCData<v8::InvocationCallback>(callback_obj); |
| 1118 |
| 1122 value = callback(new_args); | 1119 value = callback(new_args); |
| 1123 } | 1120 } |
| 1124 if (value.IsEmpty()) { | 1121 if (value.IsEmpty()) { |
| 1125 result = Heap::undefined_value(); | 1122 result = Heap::undefined_value(); |
| 1126 } else { | 1123 } else { |
| 1127 result = *reinterpret_cast<Object**>(*value); | 1124 result = *reinterpret_cast<Object**>(*value); |
| 1128 } | 1125 } |
| 1129 | 1126 |
| 1130 RETURN_IF_SCHEDULED_EXCEPTION(); | 1127 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 1131 return result; | 1128 return result; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1154 ASSERT(constructor->shared()->IsApiFunction()); | 1151 ASSERT(constructor->shared()->IsApiFunction()); |
| 1155 Object* handler = | 1152 Object* handler = |
| 1156 constructor->shared()->get_api_func_data()->instance_call_handler(); | 1153 constructor->shared()->get_api_func_data()->instance_call_handler(); |
| 1157 ASSERT(!handler->IsUndefined()); | 1154 ASSERT(!handler->IsUndefined()); |
| 1158 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); | 1155 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); |
| 1159 Object* callback_obj = call_data->callback(); | 1156 Object* callback_obj = call_data->callback(); |
| 1160 v8::InvocationCallback callback = | 1157 v8::InvocationCallback callback = |
| 1161 v8::ToCData<v8::InvocationCallback>(callback_obj); | 1158 v8::ToCData<v8::InvocationCallback>(callback_obj); |
| 1162 | 1159 |
| 1163 // Get the data for the call and perform the callback. | 1160 // Get the data for the call and perform the callback. |
| 1164 Object* data_obj = call_data->data(); | |
| 1165 Object* result; | 1161 Object* result; |
| 1166 { HandleScope scope; | 1162 { |
| 1167 v8::Local<v8::Object> self = | 1163 HandleScope scope; |
| 1168 v8::Utils::ToLocal(Handle<JSObject>::cast(args.receiver())); | 1164 |
| 1169 Handle<Object> data_handle(data_obj); | 1165 LOG(ApiObjectAccess("call non-function", obj)); |
| 1170 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle); | 1166 |
| 1171 Handle<JSFunction> callee_handle(constructor); | 1167 CustomArguments custom; |
| 1172 v8::Local<v8::Function> callee = v8::Utils::ToLocal(callee_handle); | 1168 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), |
| 1173 LOG(ApiObjectAccess("call non-function", JSObject::cast(*args.receiver()))); | 1169 call_data->data(), constructor, obj); |
| 1174 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( | 1170 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( |
| 1175 data, | 1171 custom.end(), |
| 1176 self, | 1172 &args[0] - 1, |
| 1177 callee, | 1173 args.length() - 1, |
| 1178 is_construct_call, | 1174 is_construct_call); |
| 1179 reinterpret_cast<void**>(&args[0] - 1), | |
| 1180 args.length() - 1); | |
| 1181 v8::Handle<v8::Value> value; | 1175 v8::Handle<v8::Value> value; |
| 1182 { | 1176 { |
| 1183 // Leaving JavaScript. | 1177 // Leaving JavaScript. |
| 1184 VMState state(EXTERNAL); | 1178 VMState state(EXTERNAL); |
| 1185 #ifdef ENABLE_LOGGING_AND_PROFILING | 1179 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 1186 state.set_external_callback(v8::ToCData<Address>(callback_obj)); | 1180 state.set_external_callback(v8::ToCData<Address>(callback_obj)); |
| 1187 #endif | 1181 #endif |
| 1188 value = callback(new_args); | 1182 value = callback(new_args); |
| 1189 } | 1183 } |
| 1190 if (value.IsEmpty()) { | 1184 if (value.IsEmpty()) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 Code* entry = Code::cast(builtins_[i]); | 1582 Code* entry = Code::cast(builtins_[i]); |
| 1589 if (entry->contains(pc)) { | 1583 if (entry->contains(pc)) { |
| 1590 return names_[i]; | 1584 return names_[i]; |
| 1591 } | 1585 } |
| 1592 } | 1586 } |
| 1593 } | 1587 } |
| 1594 return NULL; | 1588 return NULL; |
| 1595 } | 1589 } |
| 1596 | 1590 |
| 1597 } } // namespace v8::internal | 1591 } } // namespace v8::internal |
| OLD | NEW |