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

Side by Side Diff: src/builtins.cc

Issue 669061: First take on custom call generators. (Closed)
Patch Set: Ultimate version Created 10 years, 9 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 | « src/bootstrapper.cc ('k') | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 783 }
784 784
785 785
786 template <bool is_construct> 786 template <bool is_construct>
787 static Object* HandleApiCallHelper( 787 static Object* HandleApiCallHelper(
788 BuiltinArguments<NEEDS_CALLED_FUNCTION> args) { 788 BuiltinArguments<NEEDS_CALLED_FUNCTION> args) {
789 ASSERT(is_construct == CalledAsConstructor()); 789 ASSERT(is_construct == CalledAsConstructor());
790 790
791 HandleScope scope; 791 HandleScope scope;
792 Handle<JSFunction> function = args.called_function(); 792 Handle<JSFunction> function = args.called_function();
793 ASSERT(function->shared()->IsApiFunction());
793 794
795 FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data();
794 if (is_construct) { 796 if (is_construct) {
795 Handle<FunctionTemplateInfo> desc = 797 Handle<FunctionTemplateInfo> desc(fun_data);
796 Handle<FunctionTemplateInfo>(
797 FunctionTemplateInfo::cast(function->shared()->function_data()));
798 bool pending_exception = false; 798 bool pending_exception = false;
799 Factory::ConfigureInstance(desc, Handle<JSObject>::cast(args.receiver()), 799 Factory::ConfigureInstance(desc, Handle<JSObject>::cast(args.receiver()),
800 &pending_exception); 800 &pending_exception);
801 ASSERT(Top::has_pending_exception() == pending_exception); 801 ASSERT(Top::has_pending_exception() == pending_exception);
802 if (pending_exception) return Failure::Exception(); 802 if (pending_exception) return Failure::Exception();
803 fun_data = *desc;
803 } 804 }
804 805
805 FunctionTemplateInfo* fun_data =
806 FunctionTemplateInfo::cast(function->shared()->function_data());
807 Object* raw_holder = TypeCheck(args.length(), &args[0], fun_data); 806 Object* raw_holder = TypeCheck(args.length(), &args[0], fun_data);
808 807
809 if (raw_holder->IsNull()) { 808 if (raw_holder->IsNull()) {
810 // This function cannot be called with the given receiver. Abort! 809 // This function cannot be called with the given receiver. Abort!
811 Handle<Object> obj = 810 Handle<Object> obj =
812 Factory::NewTypeError("illegal_invocation", HandleVector(&function, 1)); 811 Factory::NewTypeError("illegal_invocation", HandleVector(&function, 1));
813 return Top::Throw(*obj); 812 return Top::Throw(*obj);
814 } 813 }
815 814
816 Object* raw_call_data = fun_data->call_code(); 815 Object* raw_call_data = fun_data->call_code();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 866
868 BUILTIN(HandleApiCallConstruct) { 867 BUILTIN(HandleApiCallConstruct) {
869 return HandleApiCallHelper<true>(args); 868 return HandleApiCallHelper<true>(args);
870 } 869 }
871 870
872 871
873 #ifdef DEBUG 872 #ifdef DEBUG
874 873
875 static void VerifyTypeCheck(Handle<JSObject> object, 874 static void VerifyTypeCheck(Handle<JSObject> object,
876 Handle<JSFunction> function) { 875 Handle<JSFunction> function) {
877 FunctionTemplateInfo* info = 876 ASSERT(function->shared()->IsApiFunction());
878 FunctionTemplateInfo::cast(function->shared()->function_data()); 877 FunctionTemplateInfo* info = function->shared()->get_api_func_data();
879 if (info->signature()->IsUndefined()) return; 878 if (info->signature()->IsUndefined()) return;
880 SignatureInfo* signature = SignatureInfo::cast(info->signature()); 879 SignatureInfo* signature = SignatureInfo::cast(info->signature());
881 Object* receiver_type = signature->receiver(); 880 Object* receiver_type = signature->receiver();
882 if (receiver_type->IsUndefined()) return; 881 if (receiver_type->IsUndefined()) return;
883 FunctionTemplateInfo* type = FunctionTemplateInfo::cast(receiver_type); 882 FunctionTemplateInfo* type = FunctionTemplateInfo::cast(receiver_type);
884 ASSERT(object->IsInstanceOf(type)); 883 ASSERT(object->IsInstanceOf(type));
885 } 884 }
886 885
887 #endif 886 #endif
888 887
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 951
953 Handle<Object> receiver = args.at<Object>(0); 952 Handle<Object> receiver = args.at<Object>(0);
954 953
955 // Get the object called. 954 // Get the object called.
956 JSObject* obj = JSObject::cast(*args.receiver()); 955 JSObject* obj = JSObject::cast(*args.receiver());
957 956
958 // Get the invocation callback from the function descriptor that was 957 // Get the invocation callback from the function descriptor that was
959 // used to create the called object. 958 // used to create the called object.
960 ASSERT(obj->map()->has_instance_call_handler()); 959 ASSERT(obj->map()->has_instance_call_handler());
961 JSFunction* constructor = JSFunction::cast(obj->map()->constructor()); 960 JSFunction* constructor = JSFunction::cast(obj->map()->constructor());
962 Object* template_info = constructor->shared()->function_data(); 961 ASSERT(constructor->shared()->IsApiFunction());
963 Object* handler = 962 Object* handler =
964 FunctionTemplateInfo::cast(template_info)->instance_call_handler(); 963 constructor->shared()->get_api_func_data()->instance_call_handler();
965 ASSERT(!handler->IsUndefined()); 964 ASSERT(!handler->IsUndefined());
966 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler); 965 CallHandlerInfo* call_data = CallHandlerInfo::cast(handler);
967 Object* callback_obj = call_data->callback(); 966 Object* callback_obj = call_data->callback();
968 v8::InvocationCallback callback = 967 v8::InvocationCallback callback =
969 v8::ToCData<v8::InvocationCallback>(callback_obj); 968 v8::ToCData<v8::InvocationCallback>(callback_obj);
970 969
971 // Get the data for the call and perform the callback. 970 // Get the data for the call and perform the callback.
972 Object* data_obj = call_data->data(); 971 Object* data_obj = call_data->data();
973 Object* result; 972 Object* result;
974 { HandleScope scope; 973 { HandleScope scope;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 if (entry->contains(pc)) { 1374 if (entry->contains(pc)) {
1376 return names_[i]; 1375 return names_[i];
1377 } 1376 }
1378 } 1377 }
1379 } 1378 }
1380 return NULL; 1379 return NULL;
1381 } 1380 }
1382 1381
1383 1382
1384 } } // namespace v8::internal 1383 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698