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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) { | 1037 BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) { |
1038 ASSERT(is_construct == CalledAsConstructor(isolate)); | 1038 ASSERT(is_construct == CalledAsConstructor(isolate)); |
1039 Heap* heap = isolate->heap(); | 1039 Heap* heap = isolate->heap(); |
1040 | 1040 |
1041 HandleScope scope(isolate); | 1041 HandleScope scope(isolate); |
1042 Handle<JSFunction> function = args.called_function(); | 1042 Handle<JSFunction> function = args.called_function(); |
1043 ASSERT(function->shared()->IsApiFunction()); | 1043 ASSERT(function->shared()->IsApiFunction()); |
1044 | 1044 |
1045 FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data(); | 1045 FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data(); |
1046 if (is_construct) { | 1046 if (is_construct) { |
1047 Handle<FunctionTemplateInfo> desc(fun_data); | 1047 Handle<FunctionTemplateInfo> desc(fun_data, isolate); |
1048 bool pending_exception = false; | 1048 bool pending_exception = false; |
1049 isolate->factory()->ConfigureInstance( | 1049 isolate->factory()->ConfigureInstance( |
1050 desc, Handle<JSObject>::cast(args.receiver()), &pending_exception); | 1050 desc, Handle<JSObject>::cast(args.receiver()), &pending_exception); |
1051 ASSERT(isolate->has_pending_exception() == pending_exception); | 1051 ASSERT(isolate->has_pending_exception() == pending_exception); |
1052 if (pending_exception) return Failure::Exception(); | 1052 if (pending_exception) return Failure::Exception(); |
1053 fun_data = *desc; | 1053 fun_data = *desc; |
1054 } | 1054 } |
1055 | 1055 |
1056 Object* raw_holder = TypeCheck(heap, args.length(), &args[0], fun_data); | 1056 Object* raw_holder = TypeCheck(heap, args.length(), &args[0], fun_data); |
1057 | 1057 |
1058 if (raw_holder->IsNull()) { | 1058 if (raw_holder->IsNull()) { |
1059 // This function cannot be called with the given receiver. Abort! | 1059 // This function cannot be called with the given receiver. Abort! |
1060 Handle<Object> obj = | 1060 Handle<Object> obj = |
1061 isolate->factory()->NewTypeError( | 1061 isolate->factory()->NewTypeError( |
1062 "illegal_invocation", HandleVector(&function, 1)); | 1062 "illegal_invocation", HandleVector(&function, 1)); |
1063 return isolate->Throw(*obj); | 1063 return isolate->Throw(*obj); |
1064 } | 1064 } |
1065 | 1065 |
1066 Object* raw_call_data = fun_data->call_code(); | 1066 Object* raw_call_data = fun_data->call_code(); |
1067 if (!raw_call_data->IsUndefined()) { | 1067 if (!raw_call_data->IsUndefined()) { |
1068 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 1068 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
1069 Object* callback_obj = call_data->callback(); | 1069 Object* callback_obj = call_data->callback(); |
1070 v8::InvocationCallback callback = | 1070 v8::InvocationCallback callback = |
1071 v8::ToCData<v8::InvocationCallback>(callback_obj); | 1071 v8::ToCData<v8::InvocationCallback>(callback_obj); |
1072 Object* data_obj = call_data->data(); | 1072 Object* data_obj = call_data->data(); |
1073 Object* result; | 1073 Object* result; |
1074 | 1074 |
1075 LOG(ApiObjectAccess("call", JSObject::cast(*args.receiver()))); | 1075 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); |
1076 ASSERT(raw_holder->IsJSObject()); | 1076 ASSERT(raw_holder->IsJSObject()); |
1077 | 1077 |
1078 CustomArguments custom(isolate); | 1078 CustomArguments custom(isolate); |
1079 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), | 1079 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), |
1080 data_obj, *function, raw_holder); | 1080 data_obj, *function, raw_holder); |
1081 | 1081 |
1082 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( | 1082 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( |
1083 custom.end(), | 1083 custom.end(), |
1084 &args[0] - 1, | 1084 &args[0] - 1, |
1085 args.length() - 1, | 1085 args.length() - 1, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 ASSERT(!handler->IsUndefined()); | 1206 ASSERT(!handler->IsUndefined()); |
1207 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); | 1207 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); |
1208 Object* callback_obj = call_data->callback(); | 1208 Object* callback_obj = call_data->callback(); |
1209 v8::InvocationCallback callback = | 1209 v8::InvocationCallback callback = |
1210 v8::ToCData<v8::InvocationCallback>(callback_obj); | 1210 v8::ToCData<v8::InvocationCallback>(callback_obj); |
1211 | 1211 |
1212 // Get the data for the call and perform the callback. | 1212 // Get the data for the call and perform the callback. |
1213 Object* result; | 1213 Object* result; |
1214 { | 1214 { |
1215 HandleScope scope(isolate); | 1215 HandleScope scope(isolate); |
1216 | 1216 LOG(isolate, ApiObjectAccess("call non-function", obj)); |
1217 LOG(ApiObjectAccess("call non-function", obj)); | |
1218 | 1217 |
1219 CustomArguments custom(isolate); | 1218 CustomArguments custom(isolate); |
1220 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), | 1219 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), |
1221 call_data->data(), constructor, obj); | 1220 call_data->data(), constructor, obj); |
1222 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( | 1221 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( |
1223 custom.end(), | 1222 custom.end(), |
1224 &args[0] - 1, | 1223 &args[0] - 1, |
1225 args.length() - 1, | 1224 args.length() - 1, |
1226 is_construct_call); | 1225 is_construct_call); |
1227 v8::Handle<v8::Value> value; | 1226 v8::Handle<v8::Value> value; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 // This simplifies things because we don't need to retry. | 1595 // This simplifies things because we don't need to retry. |
1597 AlwaysAllocateScope __scope__; | 1596 AlwaysAllocateScope __scope__; |
1598 { MaybeObject* maybe_code = | 1597 { MaybeObject* maybe_code = |
1599 heap->CreateCode(desc, flags, masm.CodeObject()); | 1598 heap->CreateCode(desc, flags, masm.CodeObject()); |
1600 if (!maybe_code->ToObject(&code)) { | 1599 if (!maybe_code->ToObject(&code)) { |
1601 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); | 1600 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); |
1602 } | 1601 } |
1603 } | 1602 } |
1604 } | 1603 } |
1605 // Log the event and add the code to the builtins array. | 1604 // Log the event and add the code to the builtins array. |
1606 PROFILE(CodeCreateEvent(Logger::BUILTIN_TAG, | 1605 PROFILE(ISOLATE, |
| 1606 CodeCreateEvent(Logger::BUILTIN_TAG, |
1607 Code::cast(code), | 1607 Code::cast(code), |
1608 functions[i].s_name)); | 1608 functions[i].s_name)); |
1609 GDBJIT(AddCode(GDBJITInterface::BUILTIN, | 1609 GDBJIT(AddCode(GDBJITInterface::BUILTIN, |
1610 functions[i].s_name, | 1610 functions[i].s_name, |
1611 Code::cast(code))); | 1611 Code::cast(code))); |
1612 builtins_[i] = code; | 1612 builtins_[i] = code; |
1613 #ifdef ENABLE_DISASSEMBLER | 1613 #ifdef ENABLE_DISASSEMBLER |
1614 if (FLAG_print_builtin_code) { | 1614 if (FLAG_print_builtin_code) { |
1615 PrintF("Builtin: %s\n", functions[i].s_name); | 1615 PrintF("Builtin: %s\n", functions[i].s_name); |
1616 Code::cast(code)->Disassemble(functions[i].s_name); | 1616 Code::cast(code)->Disassemble(functions[i].s_name); |
(...skipping 30 matching lines...) Expand all Loading... |
1647 if (entry->contains(pc)) { | 1647 if (entry->contains(pc)) { |
1648 return names_[i]; | 1648 return names_[i]; |
1649 } | 1649 } |
1650 } | 1650 } |
1651 } | 1651 } |
1652 return NULL; | 1652 return NULL; |
1653 } | 1653 } |
1654 | 1654 |
1655 | 1655 |
1656 } } // namespace v8::internal | 1656 } } // namespace v8::internal |
OLD | NEW |