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 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 i::Handle<i::ObjectTemplateInfo> obj = | 1410 i::Handle<i::ObjectTemplateInfo> obj = |
1411 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1411 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1412 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1412 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1413 int next_serial_number = 0; | 1413 int next_serial_number = 0; |
1414 if (!do_not_cache) { | 1414 if (!do_not_cache) { |
1415 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); | 1415 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); |
1416 } | 1416 } |
1417 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); | 1417 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
1418 if (!constructor.IsEmpty()) | 1418 if (!constructor.IsEmpty()) |
1419 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1419 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
1420 obj->set_internal_field_count(i::Smi::FromInt(0)); | 1420 obj->set_data(i::Smi::FromInt(0)); |
1421 return Utils::ToLocal(obj); | 1421 return Utils::ToLocal(obj); |
1422 } | 1422 } |
1423 | 1423 |
1424 Local<ObjectTemplate> ObjectTemplate::New( | 1424 Local<ObjectTemplate> ObjectTemplate::New( |
1425 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor) { | 1425 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor) { |
1426 return ObjectTemplateNew(isolate, constructor, false); | 1426 return ObjectTemplateNew(isolate, constructor, false); |
1427 } | 1427 } |
1428 | 1428 |
1429 MaybeLocal<ObjectTemplate> ObjectTemplate::FromSnapshot(Isolate* isolate, | 1429 MaybeLocal<ObjectTemplate> ObjectTemplate::FromSnapshot(Isolate* isolate, |
1430 size_t index) { | 1430 size_t index) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1705 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1706 if (data.IsEmpty()) { | 1706 if (data.IsEmpty()) { |
1707 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1707 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1708 } | 1708 } |
1709 obj->set_data(*Utils::OpenHandle(*data)); | 1709 obj->set_data(*Utils::OpenHandle(*data)); |
1710 cons->set_instance_call_handler(*obj); | 1710 cons->set_instance_call_handler(*obj); |
1711 } | 1711 } |
1712 | 1712 |
1713 | 1713 |
1714 int ObjectTemplate::InternalFieldCount() { | 1714 int ObjectTemplate::InternalFieldCount() { |
1715 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); | 1715 return Utils::OpenHandle(this)->internal_field_count(); |
1716 } | 1716 } |
1717 | 1717 |
1718 | 1718 |
1719 void ObjectTemplate::SetInternalFieldCount(int value) { | 1719 void ObjectTemplate::SetInternalFieldCount(int value) { |
1720 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1720 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1721 if (!Utils::ApiCheck(i::Smi::IsValid(value), | 1721 if (!Utils::ApiCheck(i::Smi::IsValid(value), |
1722 "v8::ObjectTemplate::SetInternalFieldCount()", | 1722 "v8::ObjectTemplate::SetInternalFieldCount()", |
1723 "Invalid internal field count")) { | 1723 "Invalid internal field count")) { |
1724 return; | 1724 return; |
1725 } | 1725 } |
1726 ENTER_V8(isolate); | 1726 ENTER_V8(isolate); |
1727 if (value > 0) { | 1727 if (value > 0) { |
1728 // The internal field count is set by the constructor function's | 1728 // The internal field count is set by the constructor function's |
1729 // construct code, so we ensure that there is a constructor | 1729 // construct code, so we ensure that there is a constructor |
1730 // function to do the setting. | 1730 // function to do the setting. |
1731 EnsureConstructor(isolate, this); | 1731 EnsureConstructor(isolate, this); |
1732 } | 1732 } |
1733 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); | 1733 Utils::OpenHandle(this)->set_internal_field_count(value); |
1734 } | 1734 } |
1735 | 1735 |
| 1736 bool ObjectTemplate::ImmutableProto() { |
| 1737 return Utils::OpenHandle(this)->immutable_proto(); |
| 1738 } |
| 1739 |
| 1740 void ObjectTemplate::SetImmutableProto() { |
| 1741 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1742 ENTER_V8(isolate); |
| 1743 Utils::OpenHandle(this)->set_immutable_proto(true); |
| 1744 } |
1736 | 1745 |
1737 // --- S c r i p t s --- | 1746 // --- S c r i p t s --- |
1738 | 1747 |
1739 | 1748 |
1740 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a | 1749 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a |
1741 // JSFunction. | 1750 // JSFunction. |
1742 | 1751 |
1743 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, | 1752 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, |
1744 BufferPolicy buffer_policy_) | 1753 BufferPolicy buffer_policy_) |
1745 : data(data_), | 1754 : data(data_), |
(...skipping 7184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8930 Address callback_address = | 8939 Address callback_address = |
8931 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8940 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8932 VMState<EXTERNAL> state(isolate); | 8941 VMState<EXTERNAL> state(isolate); |
8933 ExternalCallbackScope call_scope(isolate, callback_address); | 8942 ExternalCallbackScope call_scope(isolate, callback_address); |
8934 callback(info); | 8943 callback(info); |
8935 } | 8944 } |
8936 | 8945 |
8937 | 8946 |
8938 } // namespace internal | 8947 } // namespace internal |
8939 } // namespace v8 | 8948 } // namespace v8 |
OLD | NEW |