| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/api.h" | 7 #include "src/api.h" | 
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" | 
| 9 #include "src/base/once.h" | 9 #include "src/base/once.h" | 
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" | 
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1082 | 1082 | 
| 1083 | 1083 | 
| 1084 template <bool is_construct> | 1084 template <bool is_construct> | 
| 1085 MUST_USE_RESULT static Object* HandleApiCallHelper( | 1085 MUST_USE_RESULT static Object* HandleApiCallHelper( | 
| 1086     BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) { | 1086     BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) { | 
| 1087   DCHECK(is_construct == CalledAsConstructor(isolate)); | 1087   DCHECK(is_construct == CalledAsConstructor(isolate)); | 
| 1088   Heap* heap = isolate->heap(); | 1088   Heap* heap = isolate->heap(); | 
| 1089 | 1089 | 
| 1090   HandleScope scope(isolate); | 1090   HandleScope scope(isolate); | 
| 1091   Handle<JSFunction> function = args.called_function(); | 1091   Handle<JSFunction> function = args.called_function(); | 
| 1092   DCHECK(function->shared()->IsApiFunction()); | 1092   // TODO(ishell): turn this back to a DCHECK. | 
|  | 1093   CHECK(function->shared()->IsApiFunction()); | 
| 1093 | 1094 | 
| 1094   Handle<FunctionTemplateInfo> fun_data( | 1095   Handle<FunctionTemplateInfo> fun_data( | 
| 1095       function->shared()->get_api_func_data(), isolate); | 1096       function->shared()->get_api_func_data(), isolate); | 
| 1096   if (is_construct) { | 1097   if (is_construct) { | 
| 1097     ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1098     ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 
| 1098         isolate, fun_data, | 1099         isolate, fun_data, | 
| 1099         isolate->factory()->ConfigureInstance( | 1100         isolate->factory()->ConfigureInstance( | 
| 1100             fun_data, Handle<JSObject>::cast(args.receiver()))); | 1101             fun_data, Handle<JSObject>::cast(args.receiver()))); | 
| 1101   } | 1102   } | 
| 1102 | 1103 | 
| 1103   SharedFunctionInfo* shared = function->shared(); | 1104   SharedFunctionInfo* shared = function->shared(); | 
| 1104   if (shared->strict_mode() == SLOPPY && !shared->native()) { | 1105   if (shared->strict_mode() == SLOPPY && !shared->native()) { | 
| 1105     Object* recv = args[0]; | 1106     Object* recv = args[0]; | 
| 1106     DCHECK(!recv->IsNull()); | 1107     DCHECK(!recv->IsNull()); | 
| 1107     if (recv->IsUndefined()) args[0] = function->global_proxy(); | 1108     if (recv->IsUndefined()) args[0] = function->global_proxy(); | 
| 1108   } | 1109   } | 
| 1109 | 1110 | 
| 1110   Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data); | 1111   Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data); | 
| 1111 | 1112 | 
| 1112   if (raw_holder->IsNull()) { | 1113   if (raw_holder->IsNull()) { | 
| 1113     // This function cannot be called with the given receiver.  Abort! | 1114     // This function cannot be called with the given receiver.  Abort! | 
| 1114     THROW_NEW_ERROR_RETURN_FAILURE( | 1115     THROW_NEW_ERROR_RETURN_FAILURE( | 
| 1115         isolate, | 1116         isolate, | 
| 1116         NewTypeError("illegal_invocation", HandleVector(&function, 1))); | 1117         NewTypeError("illegal_invocation", HandleVector(&function, 1))); | 
| 1117   } | 1118   } | 
| 1118 | 1119 | 
| 1119   Object* raw_call_data = fun_data->call_code(); | 1120   Object* raw_call_data = fun_data->call_code(); | 
| 1120   if (!raw_call_data->IsUndefined()) { | 1121   if (!raw_call_data->IsUndefined()) { | 
|  | 1122     // TODO(ishell): remove this debugging code. | 
|  | 1123     CHECK(raw_call_data->IsCallHandlerInfo()); | 
| 1121     CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1124     CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 
| 1122     Object* callback_obj = call_data->callback(); | 1125     Object* callback_obj = call_data->callback(); | 
| 1123     v8::FunctionCallback callback = | 1126     v8::FunctionCallback callback = | 
| 1124         v8::ToCData<v8::FunctionCallback>(callback_obj); | 1127         v8::ToCData<v8::FunctionCallback>(callback_obj); | 
| 1125     Object* data_obj = call_data->data(); | 1128     Object* data_obj = call_data->data(); | 
| 1126     Object* result; | 1129     Object* result; | 
| 1127 | 1130 | 
| 1128     LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); | 1131     LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); | 
| 1129     DCHECK(raw_holder->IsJSObject()); | 1132     DCHECK(raw_holder->IsJSObject()); | 
| 1130 | 1133 | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1176 | 1179 | 
| 1177   Handle<Object> receiver = args.receiver(); | 1180   Handle<Object> receiver = args.receiver(); | 
| 1178 | 1181 | 
| 1179   // Get the object called. | 1182   // Get the object called. | 
| 1180   JSObject* obj = JSObject::cast(*receiver); | 1183   JSObject* obj = JSObject::cast(*receiver); | 
| 1181 | 1184 | 
| 1182   // Get the invocation callback from the function descriptor that was | 1185   // Get the invocation callback from the function descriptor that was | 
| 1183   // used to create the called object. | 1186   // used to create the called object. | 
| 1184   DCHECK(obj->map()->has_instance_call_handler()); | 1187   DCHECK(obj->map()->has_instance_call_handler()); | 
| 1185   JSFunction* constructor = JSFunction::cast(obj->map()->constructor()); | 1188   JSFunction* constructor = JSFunction::cast(obj->map()->constructor()); | 
| 1186   DCHECK(constructor->shared()->IsApiFunction()); | 1189   // TODO(ishell): turn this back to a DCHECK. | 
|  | 1190   CHECK(constructor->shared()->IsApiFunction()); | 
| 1187   Object* handler = | 1191   Object* handler = | 
| 1188       constructor->shared()->get_api_func_data()->instance_call_handler(); | 1192       constructor->shared()->get_api_func_data()->instance_call_handler(); | 
| 1189   DCHECK(!handler->IsUndefined()); | 1193   DCHECK(!handler->IsUndefined()); | 
|  | 1194   // TODO(ishell): remove this debugging code. | 
|  | 1195   CHECK(handler->IsCallHandlerInfo()); | 
| 1190   CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); | 1196   CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); | 
| 1191   Object* callback_obj = call_data->callback(); | 1197   Object* callback_obj = call_data->callback(); | 
| 1192   v8::FunctionCallback callback = | 1198   v8::FunctionCallback callback = | 
| 1193       v8::ToCData<v8::FunctionCallback>(callback_obj); | 1199       v8::ToCData<v8::FunctionCallback>(callback_obj); | 
| 1194 | 1200 | 
| 1195   // Get the data for the call and perform the callback. | 1201   // Get the data for the call and perform the callback. | 
| 1196   Object* result; | 1202   Object* result; | 
| 1197   { | 1203   { | 
| 1198     HandleScope scope(isolate); | 1204     HandleScope scope(isolate); | 
| 1199     LOG(isolate, ApiObjectAccess("call non-function", obj)); | 1205     LOG(isolate, ApiObjectAccess("call non-function", obj)); | 
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1644 } | 1650 } | 
| 1645 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1651 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 
| 1646 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1652 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 1647 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1653 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 
| 1648 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1654 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 1649 #undef DEFINE_BUILTIN_ACCESSOR_C | 1655 #undef DEFINE_BUILTIN_ACCESSOR_C | 
| 1650 #undef DEFINE_BUILTIN_ACCESSOR_A | 1656 #undef DEFINE_BUILTIN_ACCESSOR_A | 
| 1651 | 1657 | 
| 1652 | 1658 | 
| 1653 } }  // namespace v8::internal | 1659 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|