| OLD | NEW |
| 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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 obj->set_length(length); | 1125 obj->set_length(length); |
| 1126 obj->set_undetectable(false); | 1126 obj->set_undetectable(false); |
| 1127 obj->set_needs_access_check(false); | 1127 obj->set_needs_access_check(false); |
| 1128 obj->set_accept_any_receiver(true); | 1128 obj->set_accept_any_receiver(true); |
| 1129 if (!signature.IsEmpty()) | 1129 if (!signature.IsEmpty()) |
| 1130 obj->set_signature(*Utils::OpenHandle(*signature)); | 1130 obj->set_signature(*Utils::OpenHandle(*signature)); |
| 1131 return Utils::ToLocal(obj); | 1131 return Utils::ToLocal(obj); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 | 1134 |
| 1135 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, | 1135 Local<FunctionTemplate> FunctionTemplate::New( |
| 1136 FunctionCallback callback, | 1136 Isolate* isolate, FunctionCallback callback, v8::Local<Value> data, |
| 1137 v8::Local<Value> data, | 1137 v8::Local<Signature> signature, int length, ConstructorBehavior behavior) { |
| 1138 v8::Local<Signature> signature, | |
| 1139 int length) { | |
| 1140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1138 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1141 // Changes to the environment cannot be captured in the snapshot. Expect no | 1139 // Changes to the environment cannot be captured in the snapshot. Expect no |
| 1142 // function templates when the isolate is created for serialization. | 1140 // function templates when the isolate is created for serialization. |
| 1143 DCHECK(!i_isolate->serializer_enabled()); | 1141 DCHECK(!i_isolate->serializer_enabled()); |
| 1144 LOG_API(i_isolate, FunctionTemplate, New); | 1142 LOG_API(i_isolate, FunctionTemplate, New); |
| 1145 ENTER_V8(i_isolate); | 1143 ENTER_V8(i_isolate); |
| 1146 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, | 1144 auto templ = FunctionTemplateNew(i_isolate, callback, nullptr, data, |
| 1147 length, false); | 1145 signature, length, false); |
| 1146 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); |
| 1147 return templ; |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 | 1150 |
| 1151 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( | 1151 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( |
| 1152 Isolate* isolate, FunctionCallback callback, | 1152 Isolate* isolate, FunctionCallback callback, |
| 1153 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, | 1153 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, |
| 1154 v8::Local<Signature> signature, int length) { | 1154 v8::Local<Signature> signature, int length) { |
| 1155 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1155 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1156 DCHECK(!i_isolate->serializer_enabled()); | 1156 DCHECK(!i_isolate->serializer_enabled()); |
| 1157 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); | 1157 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4403 } | 4403 } |
| 4404 | 4404 |
| 4405 | 4405 |
| 4406 Local<v8::Value> Object::CallAsConstructor(int argc, | 4406 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 4407 v8::Local<v8::Value> argv[]) { | 4407 v8::Local<v8::Value> argv[]) { |
| 4408 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4408 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4409 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4409 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4410 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4410 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
| 4411 } | 4411 } |
| 4412 | 4412 |
| 4413 | |
| 4414 MaybeLocal<Function> Function::New(Local<Context> context, | 4413 MaybeLocal<Function> Function::New(Local<Context> context, |
| 4415 FunctionCallback callback, Local<Value> data, | 4414 FunctionCallback callback, Local<Value> data, |
| 4416 int length) { | 4415 int length, ConstructorBehavior behavior) { |
| 4417 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); | 4416 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); |
| 4418 LOG_API(isolate, Function, New); | 4417 LOG_API(isolate, Function, New); |
| 4419 ENTER_V8(isolate); | 4418 ENTER_V8(isolate); |
| 4420 return FunctionTemplateNew(isolate, callback, nullptr, data, | 4419 auto templ = FunctionTemplateNew(isolate, callback, nullptr, data, |
| 4421 Local<Signature>(), length, true) | 4420 Local<Signature>(), length, true); |
| 4422 ->GetFunction(context); | 4421 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); |
| 4422 return templ->GetFunction(context); |
| 4423 } | 4423 } |
| 4424 | 4424 |
| 4425 | 4425 |
| 4426 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, | 4426 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, |
| 4427 Local<Value> data, int length) { | 4427 Local<Value> data, int length) { |
| 4428 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) | 4428 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length, |
| 4429 ConstructorBehavior::kAllow) |
| 4429 .FromMaybe(Local<Function>()); | 4430 .FromMaybe(Local<Function>()); |
| 4430 } | 4431 } |
| 4431 | 4432 |
| 4432 | 4433 |
| 4433 Local<v8::Object> Function::NewInstance() const { | 4434 Local<v8::Object> Function::NewInstance() const { |
| 4434 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4435 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
| 4435 .FromMaybe(Local<Object>()); | 4436 .FromMaybe(Local<Object>()); |
| 4436 } | 4437 } |
| 4437 | 4438 |
| 4438 | 4439 |
| (...skipping 4367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8806 Address callback_address = | 8807 Address callback_address = |
| 8807 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8808 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8808 VMState<EXTERNAL> state(isolate); | 8809 VMState<EXTERNAL> state(isolate); |
| 8809 ExternalCallbackScope call_scope(isolate, callback_address); | 8810 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8810 callback(info); | 8811 callback(info); |
| 8811 } | 8812 } |
| 8812 | 8813 |
| 8813 | 8814 |
| 8814 } // namespace internal | 8815 } // namespace internal |
| 8815 } // namespace v8 | 8816 } // namespace v8 |
| OLD | NEW |