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

Side by Side Diff: src/api.cc

Issue 2133643002: Version 5.1.281.74 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.1
Patch Set: Created 4 years, 5 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 | « include/v8-version.h ('k') | 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 obj->set_signature(*Utils::OpenHandle(*signature)); 1134 obj->set_signature(*Utils::OpenHandle(*signature));
1135 return Utils::ToLocal(obj); 1135 return Utils::ToLocal(obj);
1136 } 1136 }
1137 1137
1138 1138
1139 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, 1139 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate,
1140 FunctionCallback callback, 1140 FunctionCallback callback,
1141 v8::Local<Value> data, 1141 v8::Local<Value> data,
1142 v8::Local<Signature> signature, 1142 v8::Local<Signature> signature,
1143 int length) { 1143 int length) {
1144 return New(
1145 isolate, callback, data, signature, length, ConstructorBehavior::kAllow);
1146 }
1147
1148 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate,
1149 FunctionCallback callback,
1150 v8::Local<Value> data,
1151 v8::Local<Signature> signature,
1152 int length,
1153 ConstructorBehavior behavior) {
1144 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1154 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1145 // Changes to the environment cannot be captured in the snapshot. Expect no 1155 // Changes to the environment cannot be captured in the snapshot. Expect no
1146 // function templates when the isolate is created for serialization. 1156 // function templates when the isolate is created for serialization.
1147 DCHECK(!i_isolate->serializer_enabled()); 1157 DCHECK(!i_isolate->serializer_enabled());
1148 LOG_API(i_isolate, "FunctionTemplate::New"); 1158 LOG_API(i_isolate, "FunctionTemplate::New");
1149 ENTER_V8(i_isolate); 1159 ENTER_V8(i_isolate);
1150 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, 1160 auto tmpl = FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
1151 length, false); 1161 length, false);
1162 if (behavior == ConstructorBehavior::kThrow) tmpl->RemovePrototype();
1163 return tmpl;
1152 } 1164 }
1153 1165
1154 1166
1155 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( 1167 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler(
1156 Isolate* isolate, FunctionCallback callback, 1168 Isolate* isolate, FunctionCallback callback,
1157 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1169 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1158 v8::Local<Signature> signature, int length) { 1170 v8::Local<Signature> signature, int length) {
1159 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1160 DCHECK(!i_isolate->serializer_enabled()); 1172 DCHECK(!i_isolate->serializer_enabled());
1161 LOG_API(i_isolate, "FunctionTemplate::NewWithFastHandler"); 1173 LOG_API(i_isolate, "FunctionTemplate::NewWithFastHandler");
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after
4430 v8::Local<v8::Value> argv[]) { 4442 v8::Local<v8::Value> argv[]) {
4431 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4443 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4432 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4444 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4433 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); 4445 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value);
4434 } 4446 }
4435 4447
4436 4448
4437 MaybeLocal<Function> Function::New(Local<Context> context, 4449 MaybeLocal<Function> Function::New(Local<Context> context,
4438 FunctionCallback callback, Local<Value> data, 4450 FunctionCallback callback, Local<Value> data,
4439 int length) { 4451 int length) {
4452 return New(context, callback, data, length, ConstructorBehavior::kAllow);
4453 }
4454
4455 MaybeLocal<Function> Function::New(Local<Context> context,
4456 FunctionCallback callback, Local<Value> data,
4457 int length, ConstructorBehavior behavior) {
4440 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); 4458 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
4441 LOG_API(isolate, "Function::New"); 4459 LOG_API(isolate, "Function::New");
4442 ENTER_V8(isolate); 4460 ENTER_V8(isolate);
4443 return FunctionTemplateNew(isolate, callback, nullptr, data, 4461 auto tmpl = FunctionTemplateNew(isolate, callback, nullptr, data,
4444 Local<Signature>(), length, true) 4462 Local<Signature>(), length, true);
4445 ->GetFunction(context); 4463 if (behavior == ConstructorBehavior::kThrow) tmpl->RemovePrototype();
4464 return tmpl->GetFunction(context);
4446 } 4465 }
4447 4466
4448
4449 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, 4467 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
4450 Local<Value> data, int length) { 4468 Local<Value> data, int length) {
4451 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) 4469 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length)
4452 .FromMaybe(Local<Function>()); 4470 .FromMaybe(Local<Function>());
4453 } 4471 }
4454 4472
4455 4473
4456 Local<v8::Object> Function::NewInstance() const { 4474 Local<v8::Object> Function::NewInstance() const {
4457 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) 4475 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL)
4458 .FromMaybe(Local<Object>()); 4476 .FromMaybe(Local<Object>());
(...skipping 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after
8795 Address callback_address = 8813 Address callback_address =
8796 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8814 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8797 VMState<EXTERNAL> state(isolate); 8815 VMState<EXTERNAL> state(isolate);
8798 ExternalCallbackScope call_scope(isolate, callback_address); 8816 ExternalCallbackScope call_scope(isolate, callback_address);
8799 callback(info); 8817 callback(info);
8800 } 8818 }
8801 8819
8802 8820
8803 } // namespace internal 8821 } // namespace internal
8804 } // namespace v8 8822 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698