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

Side by Side Diff: src/api.cc

Issue 23561007: add uncached Function::New (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 1045
1046 1046
1047 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 1047 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
1048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1049 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; 1049 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
1050 ENTER_V8(isolate); 1050 ENTER_V8(isolate);
1051 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 1051 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
1052 } 1052 }
1053 1053
1054 1054
1055 Local<FunctionTemplate> FunctionTemplate::New( 1055 static Local<FunctionTemplate> FunctionTemplateNew(
1056 i::Isolate* isolate,
1056 FunctionCallback callback, 1057 FunctionCallback callback,
1057 v8::Handle<Value> data, 1058 v8::Handle<Value> data,
1058 v8::Handle<Signature> signature, 1059 v8::Handle<Signature> signature,
1059 int length) { 1060 int length,
1060 i::Isolate* isolate = i::Isolate::Current(); 1061 bool do_not_cache) {
1061 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
1062 LOG_API(isolate, "FunctionTemplate::New");
1063 ENTER_V8(isolate);
1064 i::Handle<i::Struct> struct_obj = 1062 i::Handle<i::Struct> struct_obj =
1065 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 1063 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
1066 i::Handle<i::FunctionTemplateInfo> obj = 1064 i::Handle<i::FunctionTemplateInfo> obj =
1067 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 1065 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
1068 InitializeFunctionTemplate(obj); 1066 InitializeFunctionTemplate(obj);
1069 int next_serial_number = isolate->next_serial_number(); 1067 obj->set_do_not_cache(do_not_cache);
1070 isolate->set_next_serial_number(next_serial_number + 1); 1068 int next_serial_number = 0;
1069 if (!do_not_cache) {
1070 next_serial_number = isolate->next_serial_number() + 1;
1071 isolate->set_next_serial_number(next_serial_number);
1072 }
1071 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1073 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
1072 if (callback != 0) { 1074 if (callback != 0) {
1073 if (data.IsEmpty()) data = v8::Undefined(); 1075 if (data.IsEmpty()) data = v8::Undefined();
1074 Utils::ToLocal(obj)->SetCallHandler(callback, data); 1076 Utils::ToLocal(obj)->SetCallHandler(callback, data);
1075 } 1077 }
1076 obj->set_length(length); 1078 obj->set_length(length);
1077 obj->set_undetectable(false); 1079 obj->set_undetectable(false);
1078 obj->set_needs_access_check(false); 1080 obj->set_needs_access_check(false);
1079
1080 if (!signature.IsEmpty()) 1081 if (!signature.IsEmpty())
1081 obj->set_signature(*Utils::OpenHandle(*signature)); 1082 obj->set_signature(*Utils::OpenHandle(*signature));
1082 return Utils::ToLocal(obj); 1083 return Utils::ToLocal(obj);
1083 } 1084 }
1084 1085
1086 Local<FunctionTemplate> FunctionTemplate::New(
1087 FunctionCallback callback,
1088 v8::Handle<Value> data,
1089 v8::Handle<Signature> signature,
1090 int length) {
1091 i::Isolate* isolate = i::Isolate::Current();
1092 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
1093 LOG_API(isolate, "FunctionTemplate::New");
1094 ENTER_V8(isolate);
1095 return FunctionTemplateNew(
1096 isolate, callback, data, signature, length, false);
1097 }
1098
1085 1099
1086 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, 1100 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
1087 int argc, Handle<FunctionTemplate> argv[]) { 1101 int argc, Handle<FunctionTemplate> argv[]) {
1088 i::Isolate* isolate = i::Isolate::Current(); 1102 i::Isolate* isolate = i::Isolate::Current();
1089 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); 1103 EnsureInitializedForIsolate(isolate, "v8::Signature::New()");
1090 LOG_API(isolate, "Signature::New"); 1104 LOG_API(isolate, "Signature::New");
1091 ENTER_V8(isolate); 1105 ENTER_V8(isolate);
1092 i::Handle<i::Struct> struct_obj = 1106 i::Handle<i::Struct> struct_obj =
1093 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); 1107 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE);
1094 i::Handle<i::SignatureInfo> obj = 1108 i::Handle<i::SignatureInfo> obj =
(...skipping 3087 matching lines...) Expand 10 before | Expand all | Expand 10 after
4182 i::Handle<i::Object> returned = i::Execution::Call( 4196 i::Handle<i::Object> returned = i::Execution::Call(
4183 isolate, fun, obj, argc, args, &has_pending_exception); 4197 isolate, fun, obj, argc, args, &has_pending_exception);
4184 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); 4198 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
4185 ASSERT(!delegate->IsUndefined()); 4199 ASSERT(!delegate->IsUndefined());
4186 return Utils::ToLocal(scope.CloseAndEscape(returned)); 4200 return Utils::ToLocal(scope.CloseAndEscape(returned));
4187 } 4201 }
4188 return Local<v8::Object>(); 4202 return Local<v8::Object>();
4189 } 4203 }
4190 4204
4191 4205
4206 Local<Function> Function::New(Isolate* v8_isolate,
4207 FunctionCallback callback,
4208 Local<Value> data,
4209 int length) {
4210 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
4211 LOG_API(isolate, "Function::New");
4212 ENTER_V8(isolate);
4213 return FunctionTemplateNew(
4214 isolate, callback, data, Local<Signature>(), length, true)->
4215 GetFunction();
4216 }
4217
4218
4192 Local<v8::Object> Function::NewInstance() const { 4219 Local<v8::Object> Function::NewInstance() const {
4193 return NewInstance(0, NULL); 4220 return NewInstance(0, NULL);
4194 } 4221 }
4195 4222
4196 4223
4197 Local<v8::Object> Function::NewInstance(int argc, 4224 Local<v8::Object> Function::NewInstance(int argc,
4198 v8::Handle<v8::Value> argv[]) const { 4225 v8::Handle<v8::Value> argv[]) const {
4199 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4226 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4200 ON_BAILOUT(isolate, "v8::Function::NewInstance()", 4227 ON_BAILOUT(isolate, "v8::Function::NewInstance()",
4201 return Local<v8::Object>()); 4228 return Local<v8::Object>());
(...skipping 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after
7874 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7901 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7875 Address callback_address = 7902 Address callback_address =
7876 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7903 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7877 VMState<EXTERNAL> state(isolate); 7904 VMState<EXTERNAL> state(isolate);
7878 ExternalCallbackScope call_scope(isolate, callback_address); 7905 ExternalCallbackScope call_scope(isolate, callback_address);
7879 return callback(info); 7906 return callback(info);
7880 } 7907 }
7881 7908
7882 7909
7883 } } // namespace v8::internal 7910 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698