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