Commit 42ea6327 authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

[sandbox] Refactor external pointer field initialization

This CL replaces the AllocateExternalPointerEntries methods with
per-field init_##fieldname methods for every external pointer field.
These now initialize the field by allocating the external pointer table
entry for it and also set the initial value. This saves one memory write
in the typical case (what used to be AllocateExternalPointerEntries
followed by a set_##fieldname) and removes some code that can be
factored out into the (DECL_)EXTERNAL_POINTER_ACCESSORS macro.

Bug: v8:10391
Change-Id: Iac937316322910de0a8bb99b33592eca8c57a4a6
Cq-Include-Trybots: luci.v8.try:v8_linux64_heap_sandbox_dbg_ng,v8_linux_arm64_sim_heap_sandbox_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3810344Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82482}
parent 1e8a4482
......@@ -88,9 +88,8 @@ Handle<CodeDataContainer> FactoryBase<Impl>::NewCodeDataContainer(
data_container.set_code_cage_base(impl()->isolate()->code_cage_base(),
kRelaxedStore);
Isolate* isolate_for_sandbox = impl()->isolate_for_sandbox();
data_container.AllocateExternalPointerEntries(isolate_for_sandbox);
data_container.set_raw_code(Smi::zero(), SKIP_WRITE_BARRIER);
data_container.set_code_entry_point(isolate_for_sandbox, kNullAddress);
data_container.init_code_entry_point(isolate_for_sandbox, kNullAddress);
}
data_container.clear_padding();
return handle(data_container, isolate());
......
......@@ -1002,7 +1002,7 @@ Handle<StringClass> Factory::InternalizeExternalString(Handle<String> string) {
StringClass external_string =
StringClass::cast(New(map, AllocationType::kOld));
DisallowGarbageCollection no_gc;
external_string.AllocateExternalPointerEntries(isolate());
external_string.InitExternalPointerFields(isolate());
StringClass cast_string = StringClass::cast(*string);
external_string.set_length(cast_string.length());
external_string.set_raw_hash_field(cast_string.raw_hash_field());
......@@ -1136,7 +1136,7 @@ MaybeHandle<String> Factory::NewExternalStringFromOneByte(
ExternalOneByteString external_string =
ExternalOneByteString::cast(New(map, AllocationType::kOld));
DisallowGarbageCollection no_gc;
external_string.AllocateExternalPointerEntries(isolate());
external_string.InitExternalPointerFields(isolate());
external_string.set_length(static_cast<int>(length));
external_string.set_raw_hash_field(String::kEmptyHashField);
external_string.SetResource(isolate(), resource);
......@@ -1159,7 +1159,7 @@ MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
ExternalTwoByteString string =
ExternalTwoByteString::cast(New(map, AllocationType::kOld));
DisallowGarbageCollection no_gc;
string.AllocateExternalPointerEntries(isolate());
string.InitExternalPointerFields(isolate());
string.set_length(static_cast<int>(length));
string.set_raw_hash_field(String::kEmptyHashField);
string.SetResource(isolate(), resource);
......@@ -1255,14 +1255,13 @@ Handle<NativeContext> Factory::NewNativeContext() {
context.set_native_context_map(*map);
map->set_native_context(context);
// The ExternalPointerTable is a C++ object.
context.AllocateExternalPointerEntries(isolate());
context.set_scope_info(*native_scope_info());
context.set_previous(Context());
context.set_extension(*undefined_value());
context.set_errors_thrown(Smi::zero());
context.set_math_random_index(Smi::zero());
context.set_serialized_objects(*empty_fixed_array());
context.set_microtask_queue(isolate(), nullptr);
context.init_microtask_queue(isolate(), nullptr);
context.set_retained_maps(*empty_weak_array_list());
return handle(context, isolate());
}
......@@ -1438,8 +1437,10 @@ Handle<AccessorInfo> Factory::NewAccessorInfo() {
info.set_is_sloppy(true);
info.set_initial_property_attributes(NONE);
// Initializes setter, getter and js_getter fields.
info.AllocateExternalPointerEntries(isolate());
info.init_getter(isolate(), kNullAddress);
info.init_js_getter(isolate(), kNullAddress);
info.init_setter(isolate(), kNullAddress);
info.clear_padding();
return handle(info, isolate());
......@@ -1551,8 +1552,7 @@ Handle<Foreign> Factory::NewForeign(Address addr,
Foreign foreign = Foreign::cast(
AllocateRawWithImmortalMap(map.instance_size(), allocation_type, map));
DisallowGarbageCollection no_gc;
foreign.AllocateExternalPointerEntries(isolate());
foreign.set_foreign_address(isolate(), addr);
foreign.init_foreign_address(isolate(), addr);
return handle(foreign, isolate());
}
......@@ -1596,8 +1596,7 @@ Handle<WasmTypeInfo> Factory::NewWasmTypeInfo(
for (size_t i = 0; i < supertypes.size(); i++) {
result.set_supertypes(static_cast<int>(i), *supertypes[i]);
}
result.AllocateExternalPointerEntries(isolate());
result.set_foreign_address(isolate(), type_address);
result.init_foreign_address(isolate(), type_address);
result.set_instance(*instance);
return handle(result, isolate());
}
......@@ -1631,8 +1630,7 @@ Handle<WasmInternalFunction> Factory::NewWasmInternalFunction(
raw.set_map_after_allocation(*rtt);
WasmInternalFunction result = WasmInternalFunction::cast(raw);
DisallowGarbageCollection no_gc;
result.AllocateExternalPointerEntries(isolate());
result.set_call_target(isolate(), opt_call_target);
result.init_call_target(isolate(), opt_call_target);
result.set_ref(*ref);
// Default values, will be overwritten by the caller.
result.set_code(*BUILTIN_CODE(isolate(), Abort));
......@@ -1870,8 +1868,7 @@ Handle<WasmContinuationObject> Factory::NewWasmContinuationObject(
Map map = *wasm_continuation_object_map();
auto result = WasmContinuationObject::cast(
AllocateRawWithImmortalMap(map.instance_size(), allocation, map));
result.AllocateExternalPointerEntries(isolate());
result.set_jmpbuf(isolate(), jmpbuf);
result.init_jmpbuf(isolate(), jmpbuf);
result.set_stack(*managed_stack);
result.set_parent(*parent);
return handle(result, isolate());
......@@ -2453,8 +2450,7 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
Handle<JSObject> Factory::NewExternal(void* value) {
auto external =
Handle<JSExternalObject>::cast(NewJSObjectFromMap(external_map()));
external->AllocateExternalPointerEntries(isolate());
external->set_value(isolate(), value);
external->init_value(isolate(), value);
return external;
}
......@@ -3884,8 +3880,8 @@ Handle<CallHandlerInfo> Factory::NewCallHandlerInfo(bool has_no_side_effect) {
CallHandlerInfo info = CallHandlerInfo::cast(New(map, AllocationType::kOld));
DisallowGarbageCollection no_gc;
info.set_data(*undefined_value(), SKIP_WRITE_BARRIER);
// Initializes both callback and js_callback fields.
info.AllocateExternalPointerEntries(isolate());
info.init_callback(isolate(), kNullAddress);
info.init_js_callback(isolate(), kNullAddress);
return handle(info, isolate());
}
......
......@@ -39,12 +39,6 @@ bool AccessorInfo::has_getter() { return getter() != kNullAddress; }
bool AccessorInfo::has_setter() { return setter() != kNullAddress; }
void AccessorInfo::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kAccessorInfoSetterTag>(kSetterOffset, isolate);
InitExternalPointerField<kAccessorInfoGetterTag>(kGetterOffset, isolate);
InitExternalPointerField<kAccessorInfoJsGetterTag>(kJsGetterOffset, isolate);
}
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_read,
AccessorInfo::AllCanReadBit)
BIT_FIELD_ACCESSORS(AccessorInfo, flags, all_can_write,
......@@ -117,13 +111,6 @@ bool CallHandlerInfo::NextCallHasNoSideEffect() {
return false;
}
void CallHandlerInfo::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kCallHandlerInfoCallbackTag>(kCallbackOffset,
isolate);
InitExternalPointerField<kCallHandlerInfoJsCallbackTag>(kJsCallbackOffset,
isolate);
}
EXTERNAL_POINTER_ACCESSORS(CallHandlerInfo, callback, Address, kCallbackOffset,
kCallHandlerInfoCallbackTag)
......
......@@ -75,10 +75,6 @@ class AccessorInfo
class BodyDescriptor;
private:
friend class Factory;
inline void AllocateExternalPointerEntries(Isolate* isolate);
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_ACCESSOR_INFO_FLAGS()
......@@ -138,10 +134,6 @@ class CallHandlerInfo
class BodyDescriptor;
private:
friend class Factory;
inline void AllocateExternalPointerEntries(Isolate* isolate);
TQ_OBJECT_CONSTRUCTORS(CallHandlerInfo)
};
......
......@@ -1499,11 +1499,6 @@ void CodeDataContainer::set_code_cage_base(Address code_cage_base,
#endif
}
void CodeDataContainer::AllocateExternalPointerEntries(Isolate* isolate) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
InitExternalPointerField<kCodeEntryPointTag>(kCodeEntryPointOffset, isolate);
}
Code CodeDataContainer::code() const {
PtrComprCageBase cage_base = code_cage_base();
return CodeDataContainer::code(cage_base);
......@@ -1531,6 +1526,13 @@ DEF_GETTER(CodeDataContainer, code_entry_point, Address) {
isolate);
}
void CodeDataContainer::init_code_entry_point(Isolate* isolate,
Address initial_value) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
InitExternalPointerField<kCodeEntryPointTag>(kCodeEntryPointOffset, isolate,
initial_value);
}
void CodeDataContainer::set_code_entry_point(Isolate* isolate, Address value) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
WriteExternalPointerField<kCodeEntryPointTag>(kCodeEntryPointOffset, isolate,
......
......@@ -95,8 +95,6 @@ class CodeDataContainer : public HeapObject {
// the code() value.
inline void UpdateCodeEntryPoint(Isolate* isolate_for_sandbox, Code code);
inline void AllocateExternalPointerEntries(Isolate* isolate);
// Initializes internal flags field which stores cached values of some
// properties of the respective Code object.
// Available only when V8_EXTERNAL_CODE_SPACE is enabled.
......@@ -285,12 +283,16 @@ class CodeDataContainer : public HeapObject {
private:
DECL_ACCESSORS(raw_code, Object)
DECL_RELAXED_GETTER(raw_code, Object)
inline void init_code_entry_point(Isolate* isolate, Address initial_value);
inline void set_code_entry_point(Isolate* isolate, Address value);
// When V8_EXTERNAL_CODE_SPACE is enabled the flags field contains cached
// values of some flags of the from the respective Code object.
DECL_RELAXED_UINT16_ACCESSORS(flags)
template <typename IsolateT>
friend class Deserializer;
friend Factory;
friend FactoryBase<Factory>;
friend FactoryBase<LocalFactory>;
......
......@@ -266,24 +266,9 @@ Map Context::GetInitialJSArrayMap(ElementsKind kind) const {
return Map::cast(initial_js_array_map);
}
DEF_GETTER(NativeContext, microtask_queue, MicrotaskQueue*) {
Isolate* isolate = GetIsolateForSandbox(*this);
return reinterpret_cast<MicrotaskQueue*>(
ReadExternalPointerField<kNativeContextMicrotaskQueueTag>(
kMicrotaskQueueOffset, isolate));
}
void NativeContext::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kNativeContextMicrotaskQueueTag>(
kMicrotaskQueueOffset, isolate);
}
void NativeContext::set_microtask_queue(Isolate* isolate,
MicrotaskQueue* microtask_queue) {
WriteExternalPointerField<kNativeContextMicrotaskQueueTag>(
kMicrotaskQueueOffset, isolate,
reinterpret_cast<Address>(microtask_queue));
}
EXTERNAL_POINTER_ACCESSORS(NativeContext, microtask_queue, MicrotaskQueue*,
kMicrotaskQueueOffset,
kNativeContextMicrotaskQueueTag);
void NativeContext::synchronized_set_script_context_table(
ScriptContextTable script_context_table) {
......
......@@ -714,8 +714,6 @@ class NativeContext : public Context {
DECL_CAST(NativeContext)
// TODO(neis): Move some stuff from Context here.
inline void AllocateExternalPointerEntries(Isolate* isolate);
// NativeContext fields are read concurrently from background threads; any
// concurrent writes of affected fields must have acquire-release semantics,
// thus we hide the non-atomic setter. Note this doesn't protect fully since
......@@ -726,8 +724,7 @@ class NativeContext : public Context {
ReleaseStoreTag);
// [microtask_queue]: pointer to the MicrotaskQueue object.
DECL_GETTER(microtask_queue, MicrotaskQueue*)
inline void set_microtask_queue(Isolate* isolate, MicrotaskQueue* queue);
DECL_EXTERNAL_POINTER_ACCESSORS(microtask_queue, MicrotaskQueue*);
inline void synchronized_set_script_context_table(
ScriptContextTable script_context_table);
......
......@@ -21,27 +21,8 @@ namespace internal {
TQ_OBJECT_CONSTRUCTORS_IMPL(Foreign)
// static
bool Foreign::IsNormalized(Object value) {
if (value == Smi::zero()) return true;
return Foreign::cast(value).foreign_address() != kNullAddress;
}
DEF_GETTER(Foreign, foreign_address, Address) {
Isolate* isolate = GetIsolateForSandbox(*this);
return ReadExternalPointerField<kForeignForeignAddressTag>(
kForeignAddressOffset, isolate);
}
void Foreign::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kForeignForeignAddressTag>(kForeignAddressOffset,
isolate);
}
void Foreign::set_foreign_address(Isolate* isolate, Address value) {
WriteExternalPointerField<kForeignForeignAddressTag>(kForeignAddressOffset,
isolate, value);
}
EXTERNAL_POINTER_ACCESSORS(Foreign, foreign_address, Address,
kForeignAddressOffset, kForeignForeignAddressTag);
} // namespace internal
} // namespace v8
......
......@@ -18,10 +18,8 @@ namespace internal {
// Foreign describes objects pointing from JavaScript to C structures.
class Foreign : public TorqueGeneratedForeign<Foreign, HeapObject> {
public:
// [address]: field containing the address.
DECL_GETTER(foreign_address, Address)
static inline bool IsNormalized(Object object);
// [foreign_address]: field containing the address.
DECL_EXTERNAL_POINTER_ACCESSORS(foreign_address, Address);
// Dispatched behavior.
DECL_PRINTER(Foreign)
......@@ -39,15 +37,6 @@ class Foreign : public TorqueGeneratedForeign<Foreign, HeapObject> {
class BodyDescriptor;
private:
friend class Factory;
friend class SerializerDeserializer;
friend class StartupSerializer;
friend class WasmTypeInfo;
inline void AllocateExternalPointerEntries(Isolate* isolate);
inline void set_foreign_address(Isolate* isolate, Address value);
TQ_OBJECT_CONSTRUCTORS(Foreign)
};
......
......@@ -570,20 +570,8 @@ void JSObject::InitializeBody(Map map, int start_offset,
TQ_OBJECT_CONSTRUCTORS_IMPL(JSExternalObject)
DEF_GETTER(JSExternalObject, value, void*) {
Isolate* isolate = GetIsolateForSandbox(*this);
return reinterpret_cast<void*>(
ReadExternalPointerField<kExternalObjectValueTag>(kValueOffset, isolate));
}
void JSExternalObject::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kExternalObjectValueTag>(kValueOffset, isolate);
}
void JSExternalObject::set_value(Isolate* isolate, void* value) {
WriteExternalPointerField<kExternalObjectValueTag>(
kValueOffset, isolate, reinterpret_cast<Address>(value));
}
EXTERNAL_POINTER_ACCESSORS(JSExternalObject, value, void*, kValueOffset,
kExternalObjectValueTag);
DEF_GETTER(JSGlobalObject, native_context_unchecked, Object) {
return TaggedField<Object, kNativeContextOffset>::Relaxed_Load(cage_base,
......
......@@ -911,12 +911,8 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
class JSExternalObject
: public TorqueGeneratedJSExternalObject<JSExternalObject, JSObject> {
public:
inline void AllocateExternalPointerEntries(Isolate* isolate);
// [value]: field containing the pointer value.
DECL_GETTER(value, void*)
inline void set_value(Isolate* isolate, void* value);
DECL_EXTERNAL_POINTER_ACCESSORS(value, void*)
static constexpr int kEndOfTaggedFieldsOffset = JSObject::kHeaderSize;
......
......@@ -398,9 +398,10 @@
kRelaxedStore); \
}
#define DECL_EXTERNAL_POINTER_ACCESSORS(name, type) \
inline type name() const; \
inline type name(i::Isolate* isolate_for_sandbox) const; \
#define DECL_EXTERNAL_POINTER_ACCESSORS(name, type) \
inline type name() const; \
inline type name(i::Isolate* isolate_for_sandbox) const; \
inline void init_##name(i::Isolate* isolate, type initial_value); \
inline void set_##name(i::Isolate* isolate, type value);
#define EXTERNAL_POINTER_ACCESSORS(holder, name, type, offset, tag) \
......@@ -416,6 +417,14 @@
Object::ReadExternalPointerField<tag>(offset, isolate_for_sandbox); \
return reinterpret_cast<type>(reinterpret_cast<C2440*>(result)); \
} \
void holder::init_##name(i::Isolate* isolate, type initial_value) { \
/* This is a workaround for MSVC error C2440 not allowing */ \
/* reinterpret casts to the same type. */ \
struct C2440 {}; \
Address the_value = \
reinterpret_cast<Address>(reinterpret_cast<C2440*>(initial_value)); \
Object::InitExternalPointerField<tag>(offset, isolate, the_value); \
} \
void holder::set_##name(i::Isolate* isolate, type value) { \
/* This is a workaround for MSVC error C2440 not allowing */ \
/* reinterpret casts to the same type. */ \
......
......@@ -662,11 +662,6 @@ void Object::WriteSandboxedPointerField(size_t offset, Isolate* isolate,
PtrComprCageBase(isolate), value);
}
template <ExternalPointerTag tag>
void Object::InitExternalPointerField(size_t offset, Isolate* isolate) {
i::InitExternalPointerField<tag>(field_address(offset), isolate);
}
template <ExternalPointerTag tag>
void Object::InitExternalPointerField(size_t offset, Isolate* isolate,
Address value) {
......
......@@ -733,8 +733,6 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
// ExternalPointer_t field accessors.
//
template <ExternalPointerTag tag>
inline void InitExternalPointerField(size_t offset, Isolate* isolate);
template <ExternalPointerTag tag>
inline void InitExternalPointerField(size_t offset, Isolate* isolate,
Address value);
template <ExternalPointerTag tag>
......
......@@ -1100,12 +1100,12 @@ bool ExternalString::is_uncached() const {
return (type & kUncachedExternalStringMask) == kUncachedExternalStringTag;
}
void ExternalString::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kExternalStringResourceTag>(kResourceOffset,
isolate);
void ExternalString::InitExternalPointerFields(Isolate* isolate) {
InitExternalPointerField<kExternalStringResourceTag>(kResourceOffset, isolate,
kNullAddress);
if (is_uncached()) return;
InitExternalPointerField<kExternalStringResourceDataTag>(kResourceDataOffset,
isolate);
InitExternalPointerField<kExternalStringResourceDataTag>(
kResourceDataOffset, isolate, kNullAddress);
}
DEF_GETTER(ExternalString, resource_as_address, Address) {
......
......@@ -309,7 +309,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
this->set_map(new_map, kReleaseStore);
ExternalTwoByteString self = ExternalTwoByteString::cast(*this);
self.AllocateExternalPointerEntries(isolate);
self.InitExternalPointerFields(isolate);
self.SetResource(isolate, resource);
isolate->heap()->RegisterExternalString(*this);
// Force regeneration of the hash value.
......@@ -393,7 +393,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
this->set_map(new_map, kReleaseStore);
ExternalOneByteString self = ExternalOneByteString::cast(*this);
self.AllocateExternalPointerEntries(isolate);
self.InitExternalPointerFields(isolate);
self.SetResource(isolate, resource);
isolate->heap()->RegisterExternalString(*this);
// Force regeneration of the hash value.
......
......@@ -910,7 +910,7 @@ class ExternalString
static const int kUncachedSize =
kResourceOffset + FIELD_SIZE(kResourceOffset);
inline void AllocateExternalPointerEntries(Isolate* isolate);
inline void InitExternalPointerFields(Isolate* isolate);
// Return whether the external string data pointer is not cached.
inline bool is_uncached() const;
......
......@@ -30,12 +30,6 @@ ExternalPointerTable& GetExternalPointerTable(Isolate* isolate) {
}
#endif // V8_ENABLE_SANDBOX
template <ExternalPointerTag tag>
V8_INLINE void InitExternalPointerField(Address field_address,
Isolate* isolate) {
InitExternalPointerField<tag>(field_address, isolate, kNullAddress);
}
template <ExternalPointerTag tag>
V8_INLINE void InitExternalPointerField(Address field_address, Isolate* isolate,
Address value) {
......
......@@ -13,27 +13,23 @@ namespace internal {
constexpr ExternalPointer_t kNullExternalPointer = 0;
constexpr ExternalPointerHandle kNullExternalPointerHandle = 0;
// Creates zero-initialized entry in external pointer table and writes the entry
// id to the field. When sandbox is not enabled, it's a no-op.
template <ExternalPointerTag tag>
V8_INLINE void InitExternalPointerField(Address field_address,
Isolate* isolate);
// Creates and initializes entry in external pointer table and writes the entry
// id to the field.
// Basically, it's InitExternalPointerField() followed by
// WriteExternalPointerField().
// Creates and initializes an entry in the external pointer table and writes the
// handle for that entry to the field.
template <ExternalPointerTag tag>
V8_INLINE void InitExternalPointerField(Address field_address, Isolate* isolate,
Address value);
// Reads external pointer for the field, and decodes it if the sandbox is
// enabled.
// If the sandbox is enabled: reads the ExternalPointerHandle from the field and
// loads the corresponding external pointer from the external pointer table. If
// the sandbox is disabled: load the external pointer from the field.
template <ExternalPointerTag tag>
V8_INLINE Address ReadExternalPointerField(Address field_address,
const Isolate* isolate);
// Encodes value if the sandbox is enabled and writes it into the field.
// If the sandbox is enabled: reads the ExternalPointerHandle from the field and
// stores the external pointer to the corresponding entry in the external
// pointer table. If the sandbox is disabled: stores the external pointer to the
// field.
template <ExternalPointerTag tag>
V8_INLINE void WriteExternalPointerField(Address field_address,
Isolate* isolate, Address value);
......
......@@ -345,7 +345,7 @@ void PostProcessExternalString(ExternalString string, Isolate* isolate) {
uint32_t index = string.GetResourceRefForDeserialization();
Address address =
static_cast<Address>(isolate->api_external_references()[index]);
string.AllocateExternalPointerEntries(isolate);
string.InitExternalPointerFields(isolate);
string.set_address_as_resource(isolate, address);
isolate->heap()->UpdateExternalString(string, 0,
string.ExternalPayloadSize());
......@@ -486,7 +486,8 @@ void Deserializer<IsolateT>::PostProcessNewObject(Handle<Map> map,
InstanceTypeChecker::IsCodeDataContainer(instance_type)) {
auto code_data_container = CodeDataContainer::cast(raw_obj);
code_data_container.set_code_cage_base(isolate()->code_cage_base());
code_data_container.AllocateExternalPointerEntries(main_thread_isolate());
code_data_container.init_code_entry_point(main_thread_isolate(),
kNullAddress);
code_data_container.UpdateCodeEntryPoint(main_thread_isolate(),
code_data_container.code());
} else if (InstanceTypeChecker::IsMap(instance_type)) {
......@@ -516,8 +517,8 @@ void Deserializer<IsolateT>::PostProcessNewObject(Handle<Map> map,
Handle<DescriptorArray> descriptors = Handle<DescriptorArray>::cast(obj);
new_descriptor_arrays_.push_back(descriptors);
} else if (InstanceTypeChecker::IsNativeContext(instance_type)) {
NativeContext::cast(raw_obj).AllocateExternalPointerEntries(
main_thread_isolate());
NativeContext::cast(raw_obj).init_microtask_queue(main_thread_isolate(),
nullptr);
} else if (InstanceTypeChecker::IsScript(instance_type)) {
LogScriptEvents(Script::cast(*obj));
}
......
......@@ -293,11 +293,6 @@ EXTERNAL_POINTER_ACCESSORS(WasmInternalFunction, call_target, Address,
kCallTargetOffset,
kWasmInternalFunctionCallTargetTag)
void WasmInternalFunction::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kWasmInternalFunctionCallTargetTag>(
kCallTargetOffset, isolate);
}
// WasmFunctionData
ACCESSORS(WasmFunctionData, internal, WasmInternalFunction, kInternalOffset)
......@@ -643,10 +638,6 @@ int WasmArray::DecodeElementSizeFromMap(Map map) { return map.WasmByte1(); }
EXTERNAL_POINTER_ACCESSORS(WasmContinuationObject, jmpbuf, Address,
kJmpbufOffset, kWasmContinuationJmpbufTag)
void WasmContinuationObject::AllocateExternalPointerEntries(Isolate* isolate) {
InitExternalPointerField<kWasmContinuationJmpbufTag>(kJmpbufOffset, isolate);
}
#include "src/objects/object-macros-undef.h"
} // namespace internal
......
......@@ -765,11 +765,6 @@ class WasmInternalFunction
class BodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(WasmInternalFunction)
private:
friend class Factory;
inline void AllocateExternalPointerEntries(Isolate* isolate);
};
// Information for a WasmJSFunction which is referenced as the function data of
......@@ -1037,16 +1032,12 @@ class WasmContinuationObject
class BodyDescriptor;
private:
friend class Factory;
static Handle<WasmContinuationObject> New(
Isolate* isolate, std::unique_ptr<wasm::StackMemory> stack,
Handle<HeapObject> parent,
AllocationType allocation_type = AllocationType::kYoung);
TQ_OBJECT_CONSTRUCTORS(WasmContinuationObject)
inline void AllocateExternalPointerEntries(Isolate* isolate);
};
// The suspender object provides an API to suspend and resume wasm code using
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment