Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: src/builtins.cc

Issue 846613002: Verify that Api function's instance call handler is actually a CallHandlerInfo structure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DCHECK(function->shared()->IsApiFunction());
Jakob Kummerow 2015/01/09 11:49:53 Let's temporarily turn this (and line 1188) into a
Igor Sheludko 2015/01/09 11:52:05 Done.
1093 1093
1094 Handle<FunctionTemplateInfo> fun_data( 1094 Handle<FunctionTemplateInfo> fun_data(
1095 function->shared()->get_api_func_data(), isolate); 1095 function->shared()->get_api_func_data(), isolate);
1096 if (is_construct) { 1096 if (is_construct) {
1097 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1097 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1098 isolate, fun_data, 1098 isolate, fun_data,
1099 isolate->factory()->ConfigureInstance( 1099 isolate->factory()->ConfigureInstance(
1100 fun_data, Handle<JSObject>::cast(args.receiver()))); 1100 fun_data, Handle<JSObject>::cast(args.receiver())));
1101 } 1101 }
1102 1102
1103 SharedFunctionInfo* shared = function->shared(); 1103 SharedFunctionInfo* shared = function->shared();
1104 if (shared->strict_mode() == SLOPPY && !shared->native()) { 1104 if (shared->strict_mode() == SLOPPY && !shared->native()) {
1105 Object* recv = args[0]; 1105 Object* recv = args[0];
1106 DCHECK(!recv->IsNull()); 1106 DCHECK(!recv->IsNull());
1107 if (recv->IsUndefined()) args[0] = function->global_proxy(); 1107 if (recv->IsUndefined()) args[0] = function->global_proxy();
1108 } 1108 }
1109 1109
1110 Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data); 1110 Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data);
1111 1111
1112 if (raw_holder->IsNull()) { 1112 if (raw_holder->IsNull()) {
1113 // This function cannot be called with the given receiver. Abort! 1113 // This function cannot be called with the given receiver. Abort!
1114 THROW_NEW_ERROR_RETURN_FAILURE( 1114 THROW_NEW_ERROR_RETURN_FAILURE(
1115 isolate, 1115 isolate,
1116 NewTypeError("illegal_invocation", HandleVector(&function, 1))); 1116 NewTypeError("illegal_invocation", HandleVector(&function, 1)));
1117 } 1117 }
1118 1118
1119 Object* raw_call_data = fun_data->call_code(); 1119 Object* raw_call_data = fun_data->call_code();
1120 if (!raw_call_data->IsUndefined()) { 1120 if (!raw_call_data->IsUndefined()) {
1121 // TODO(ishell): remove this debugging code.
1122 CHECK(raw_call_data->IsCallHandlerInfo());
1121 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); 1123 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
1122 Object* callback_obj = call_data->callback(); 1124 Object* callback_obj = call_data->callback();
1123 v8::FunctionCallback callback = 1125 v8::FunctionCallback callback =
1124 v8::ToCData<v8::FunctionCallback>(callback_obj); 1126 v8::ToCData<v8::FunctionCallback>(callback_obj);
1125 Object* data_obj = call_data->data(); 1127 Object* data_obj = call_data->data();
1126 Object* result; 1128 Object* result;
1127 1129
1128 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); 1130 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver())));
1129 DCHECK(raw_holder->IsJSObject()); 1131 DCHECK(raw_holder->IsJSObject());
1130 1132
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 JSObject* obj = JSObject::cast(*receiver); 1182 JSObject* obj = JSObject::cast(*receiver);
1181 1183
1182 // Get the invocation callback from the function descriptor that was 1184 // Get the invocation callback from the function descriptor that was
1183 // used to create the called object. 1185 // used to create the called object.
1184 DCHECK(obj->map()->has_instance_call_handler()); 1186 DCHECK(obj->map()->has_instance_call_handler());
1185 JSFunction* constructor = JSFunction::cast(obj->map()->constructor()); 1187 JSFunction* constructor = JSFunction::cast(obj->map()->constructor());
1186 DCHECK(constructor->shared()->IsApiFunction()); 1188 DCHECK(constructor->shared()->IsApiFunction());
1187 Object* handler = 1189 Object* handler =
1188 constructor->shared()->get_api_func_data()->instance_call_handler(); 1190 constructor->shared()->get_api_func_data()->instance_call_handler();
1189 DCHECK(!handler->IsUndefined()); 1191 DCHECK(!handler->IsUndefined());
1192 // TODO(ishell): remove this debugging code.
1193 CHECK(handler->IsCallHandlerInfo());
1190 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); 1194 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler);
1191 Object* callback_obj = call_data->callback(); 1195 Object* callback_obj = call_data->callback();
1192 v8::FunctionCallback callback = 1196 v8::FunctionCallback callback =
1193 v8::ToCData<v8::FunctionCallback>(callback_obj); 1197 v8::ToCData<v8::FunctionCallback>(callback_obj);
1194 1198
1195 // Get the data for the call and perform the callback. 1199 // Get the data for the call and perform the callback.
1196 Object* result; 1200 Object* result;
1197 { 1201 {
1198 HandleScope scope(isolate); 1202 HandleScope scope(isolate);
1199 LOG(isolate, ApiObjectAccess("call non-function", obj)); 1203 LOG(isolate, ApiObjectAccess("call non-function", obj));
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 } 1648 }
1645 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1649 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1646 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1650 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1647 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1651 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1648 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1652 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1649 #undef DEFINE_BUILTIN_ACCESSOR_C 1653 #undef DEFINE_BUILTIN_ACCESSOR_C
1650 #undef DEFINE_BUILTIN_ACCESSOR_A 1654 #undef DEFINE_BUILTIN_ACCESSOR_A
1651 1655
1652 1656
1653 } } // namespace v8::internal 1657 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698