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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1054 |
1055 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, | 1055 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, |
1056 v8::PropertyAttribute attribute) { | 1056 v8::PropertyAttribute attribute) { |
1057 auto templ = Utils::OpenHandle(this); | 1057 auto templ = Utils::OpenHandle(this); |
1058 i::Isolate* isolate = templ->GetIsolate(); | 1058 i::Isolate* isolate = templ->GetIsolate(); |
1059 ENTER_V8(isolate); | 1059 ENTER_V8(isolate); |
1060 i::HandleScope scope(isolate); | 1060 i::HandleScope scope(isolate); |
1061 auto value_obj = Utils::OpenHandle(*value); | 1061 auto value_obj = Utils::OpenHandle(*value); |
1062 CHECK(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo()); | 1062 CHECK(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo()); |
1063 if (value_obj->IsObjectTemplateInfo()) { | 1063 if (value_obj->IsObjectTemplateInfo()) { |
1064 templ->set_serial_number(i::Smi::kZero); | 1064 templ->set_serial_number(i::Smi::FromInt(0)); |
1065 if (templ->IsFunctionTemplateInfo()) { | 1065 if (templ->IsFunctionTemplateInfo()) { |
1066 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true); | 1066 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true); |
1067 } | 1067 } |
1068 } | 1068 } |
1069 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), | 1069 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), |
1070 value_obj, | 1070 value_obj, |
1071 static_cast<i::PropertyAttributes>(attribute)); | 1071 static_cast<i::PropertyAttributes>(attribute)); |
1072 } | 1072 } |
1073 | 1073 |
1074 | 1074 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 i::Handle<i::ObjectTemplateInfo> obj = | 1388 i::Handle<i::ObjectTemplateInfo> obj = |
1389 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1389 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1390 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1390 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1391 int next_serial_number = 0; | 1391 int next_serial_number = 0; |
1392 if (!do_not_cache) { | 1392 if (!do_not_cache) { |
1393 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); | 1393 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); |
1394 } | 1394 } |
1395 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); | 1395 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
1396 if (!constructor.IsEmpty()) | 1396 if (!constructor.IsEmpty()) |
1397 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1397 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
1398 obj->set_data(i::Smi::kZero); | 1398 obj->set_data(i::Smi::FromInt(0)); |
1399 return Utils::ToLocal(obj); | 1399 return Utils::ToLocal(obj); |
1400 } | 1400 } |
1401 | 1401 |
1402 Local<ObjectTemplate> ObjectTemplate::New( | 1402 Local<ObjectTemplate> ObjectTemplate::New( |
1403 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor) { | 1403 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor) { |
1404 return ObjectTemplateNew(isolate, constructor, false); | 1404 return ObjectTemplateNew(isolate, constructor, false); |
1405 } | 1405 } |
1406 | 1406 |
1407 MaybeLocal<ObjectTemplate> ObjectTemplate::FromSnapshot(Isolate* isolate, | 1407 MaybeLocal<ObjectTemplate> ObjectTemplate::FromSnapshot(Isolate* isolate, |
1408 size_t index) { | 1408 size_t index) { |
(...skipping 8013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9422 Address callback_address = | 9422 Address callback_address = |
9423 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9423 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9424 VMState<EXTERNAL> state(isolate); | 9424 VMState<EXTERNAL> state(isolate); |
9425 ExternalCallbackScope call_scope(isolate, callback_address); | 9425 ExternalCallbackScope call_scope(isolate, callback_address); |
9426 callback(info); | 9426 callback(info); |
9427 } | 9427 } |
9428 | 9428 |
9429 | 9429 |
9430 } // namespace internal | 9430 } // namespace internal |
9431 } // namespace v8 | 9431 } // namespace v8 |
OLD | NEW |