From e7f431f923887e35fb6a95b38564cd93abf95d8f Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:40:04 +0000 Subject: [PATCH 1/8] src: remove class_Map__instance_attributes__int This is not present in any release lines. --- src/llv8-constants.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index 15d85d85..5bdd851b 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -81,14 +81,8 @@ void HeapObject::Load() { void Map::Load() { Error err; - kInstanceAttrsOffset = LoadConstant({"class_Map__instance_attributes__int", - "class_Map__instance_type__uint16_t"}); - if (kInstanceAttrsOffset.name() == - "v8dbg_class_Map__instance_type__uint16_t") { - kMapTypeMask = 0xffff; - } else { - kMapTypeMask = 0xff; - } + kInstanceAttrsOffset = LoadConstant({"class_Map__instance_type__uint16_t"}); + kMapTypeMask = 0xffff; kMaybeConstructorOffset = LoadConstant("class_Map__constructor_or_backpointer__Object", From 406213bd25bf3d08d8fa98b077e225800004f646 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:40:23 +0000 Subject: [PATCH 2/8] src: remove class_JSObject__properties__FixedArray This is not present in any supported release lines. --- src/llv8-constants.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index 5bdd851b..87ab9bd6 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -144,9 +144,6 @@ void JSObject::Load() { LoadConstant("class_JSReceiver__raw_properties_or_hash__Object", "class_JSReceiver__properties__FixedArray"); - if (kPropertiesOffset == -1) - kPropertiesOffset = LoadConstant("class_JSObject__properties__FixedArray"); - kElementsOffset = LoadConstant("class_JSObject__elements__Object"); kInternalFieldsOffset = LoadConstant("class_JSObject__internal_fields__uintptr_t"); From ea5e884610a6ee060651d03efe8b4e7cd1e0fcd2 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:41:05 +0000 Subject: [PATCH 3/8] src: remove ScopeInfo/SharedInfo fields * `kScriptOffset` is never present (it's replaced by `kScriptOrDebugInfoOffset`) * `kScopeInfoOffset` also no longer present. Simplify the resulting branch. * `kStackLocalCountOffset` is no longer present, making `kEmbeddedParamAndStackLocals` always false. Remove some dead code as a result. --- src/llv8-constants.cc | 18 +++--------------- src/llv8-constants.h | 4 ---- src/llv8-inl.h | 31 ------------------------------- src/llv8.h | 3 --- src/printer.cc | 5 ----- 5 files changed, 3 insertions(+), 58 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index 87ab9bd6..d5f0003f 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -201,7 +201,6 @@ void SharedInfo::Load() { kInferredNameOffset = LoadConstant("class_SharedFunctionInfo__inferred_name__String", "class_SharedFunctionInfo__function_identifier__Object"); - kScriptOffset = LoadConstant("class_SharedFunctionInfo__script__Object"); kScriptOrDebugInfoOffset = LoadConstant( {"class_SharedFunctionInfo__script_or_debug_info__Object", "class_SharedFunctionInfo__script_or_debug_info__HeapObject"}); @@ -221,18 +220,9 @@ void SharedInfo::Load() { "class_SharedFunctionInfo__formal_parameter_count__SMI"); } - // NOTE: Could potentially be -1 on v4 and v5 node, should check in llv8 - kScopeInfoOffset = - LoadConstant("class_SharedFunctionInfo__scope_info__ScopeInfo"); - - kStartPositionMask = LoadConstant("sharedfunctioninfo_start_position_mask"); - kStartPositionShift = LoadConstant("sharedfunctioninfo_start_position_shift"); - - if (kStartPositionShift == -1) { - // TODO(indutny): check version? - kStartPositionShift = 2; - kStartPositionMask = ~((1 << kStartPositionShift) - 1); - } + // TODO: this should use postmortem data. + kStartPositionShift = 2; + kStartPositionMask = ~((1 << kStartPositionShift) - 1); if (LoadConstant("class_SharedFunctionInfo__compiler_hints__int") == -1 && kNameOrScopeInfoOffset == -1) @@ -260,8 +250,6 @@ void Code::Load() { void ScopeInfo::Load() { kParameterCountOffset = LoadConstant("scopeinfo_idx_nparams"); - kStackLocalCountOffset = LoadConstant("scopeinfo_idx_nstacklocals"); - kEmbeddedParamAndStackLocals = kStackLocalCountOffset != -1; kContextLocalCountOffset = LoadConstant("scopeinfo_idx_ncontextlocals"); kVariablePartIndex = LoadConstant("scopeinfo_idx_first_vars"); // Prior to Node.js v16, ScopeInfo inherited from FixedArray. In release diff --git a/src/llv8-constants.h b/src/llv8-constants.h index 8a86a0a5..9387adcc 100644 --- a/src/llv8-constants.h +++ b/src/llv8-constants.h @@ -159,12 +159,10 @@ class SharedInfo : public Module { int64_t kNameOrScopeInfoOffset; int64_t kNameOffset; int64_t kInferredNameOffset; - int64_t kScriptOffset; Constant kScriptOrDebugInfoOffset; int64_t kStartPositionOffset; int64_t kEndPositionOffset; int64_t kParameterCountOffset; - int64_t kScopeInfoOffset; int64_t kFunctionDataOffset; int64_t kStartPositionMask; @@ -203,9 +201,7 @@ class ScopeInfo : public Module { CONSTANTS_DEFAULT_METHODS(ScopeInfo); int64_t kParameterCountOffset; - int64_t kStackLocalCountOffset; int64_t kContextLocalCountOffset; - bool kEmbeddedParamAndStackLocals; int64_t kVariablePartIndex; bool kIsFixedArray; diff --git a/src/llv8-inl.h b/src/llv8-inl.h index e649dc6e..b8f11872 100644 --- a/src/llv8-inl.h +++ b/src/llv8-inl.h @@ -495,11 +495,8 @@ ACCESSOR(SharedFunctionInfo, function_data, shared_info()->kFunctionDataOffset, ACCESSOR(SharedFunctionInfo, name, shared_info()->kNameOffset, String) ACCESSOR(SharedFunctionInfo, inferred_name, shared_info()->kInferredNameOffset, Value) -ACCESSOR(SharedFunctionInfo, script, shared_info()->kScriptOffset, Script) SAFE_ACCESSOR(SharedFunctionInfo, script_or_debug_info, shared_info()->kScriptOrDebugInfoOffset, HeapObject) -ACCESSOR(SharedFunctionInfo, scope_info, shared_info()->kScopeInfoOffset, - HeapObject) ACCESSOR(SharedFunctionInfo, name_or_scope_info, shared_info()->kNameOrScopeInfoOffset, HeapObject) @@ -535,8 +532,6 @@ Value SharedFunctionInfo::GetInferredName(Error& err) { } HeapObject SharedFunctionInfo::GetScopeInfo(Error& err) { - if (v8()->shared_info()->kNameOrScopeInfoOffset == -1) return scope_info(err); - HeapObject maybe_scope_info = name_or_scope_info(err); if (!String::IsString(v8(), maybe_scope_info, err)) return maybe_scope_info; @@ -545,10 +540,6 @@ HeapObject SharedFunctionInfo::GetScopeInfo(Error& err) { } Script SharedFunctionInfo::GetScript(Error& err) { - if (!v8()->shared_info()->kScriptOrDebugInfoOffset.Loaded()) { - return script(err); - } - HeapObject maybe_script = script_or_debug_info(err); if (maybe_script.IsScript(err)) return maybe_script; @@ -1110,18 +1101,6 @@ inline Smi ScopeInfo::ParameterCount(Error& err) { err); } -inline Smi ScopeInfo::StackLocalCount(Error& err) { - if (v8()->scope_info()->kStackLocalCountOffset == -1) { - return Smi(v8(), 0); - } - int64_t data_offset = - v8()->scope_info()->kIsFixedArray ? v8()->fixed_array()->kDataOffset : 0; - return HeapObject::LoadFieldValue( - data_offset + v8()->scope_info()->kStackLocalCountOffset * - v8()->common()->kPointerSize, - err); -} - inline Smi ScopeInfo::ContextLocalCount(Error& err) { int64_t data_offset = v8()->scope_info()->kIsFixedArray ? v8()->fixed_array()->kDataOffset @@ -1134,16 +1113,6 @@ inline Smi ScopeInfo::ContextLocalCount(Error& err) { inline int ScopeInfo::ContextLocalIndex(Error& err) { int context_local_index = v8()->scope_info()->kVariablePartIndex; - - if (v8()->scope_info()->kEmbeddedParamAndStackLocals) { - Smi param_count = ParameterCount(err); - if (err.Fail()) return -1; - context_local_index += param_count.GetValue() + 1; - - Smi stack_local = StackLocalCount(err); - if (err.Fail()) return -1; - context_local_index += stack_local.GetValue(); - } return context_local_index; } diff --git a/src/llv8.h b/src/llv8.h index a5f43998..87e0db35 100644 --- a/src/llv8.h +++ b/src/llv8.h @@ -217,11 +217,9 @@ class SharedFunctionInfo : public HeapObject { private: inline String name(Error& err); - inline Script script(Error& err); inline HeapObject script_or_debug_info(Error& err); inline Value inferred_name(Error& err); inline Value function_data(Error& err); - inline HeapObject scope_info(Error& err); inline HeapObject name_or_scope_info(Error& err); }; @@ -520,7 +518,6 @@ class ScopeInfo : public HeapObject { }; inline Smi ParameterCount(Error& err); - inline Smi StackLocalCount(Error& err); inline Smi ContextLocalCount(Error& err); inline int ContextLocalIndex(Error& err); inline PositionInfo MaybePositionInfo(Error& err); diff --git a/src/printer.cc b/src/printer.cc index 377adc34..329392af 100644 --- a/src/printer.cc +++ b/src/printer.cc @@ -203,11 +203,6 @@ std::string Printer::Stringify(v8::FixedArray fixed_array, Error& err) { template <> std::string Printer::Stringify(v8::Context ctx, Error& err) { - // Not enough postmortem information, return bare minimum - if (llv8_->shared_info()->kScopeInfoOffset == -1 && - llv8_->shared_info()->kNameOrScopeInfoOffset == -1) - return std::string(); - std::string res = " Date: Sat, 24 Sep 2022 06:12:23 +0000 Subject: [PATCH 4/8] src: remove "native_context" field Not present in any supported release branches. --- src/llv8-constants.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index d5f0003f..2d6809af 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -268,9 +268,6 @@ void Context::Load() { // of constants or a fallback list). kNativeIndex = LoadConstant("class_Context__native_index__int", "context_idx_native"); - if (kNativeIndex == -1) { - kNativeIndex = LoadConstant("class_Context__native_context_index__int"); - } kEmbedderDataIndex = LoadConstant("context_idx_embedder_data", (int)5); kMinContextSlots = LoadConstant("class_Context__min_context_slots__int", From e2a135592d13edb7c2992cf20931ccac6a9f55a7 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 06:12:45 +0000 Subject: [PATCH 5/8] src: remove support for Smi string lengths This is unused in all supported release branches. --- src/llv8-constants.cc | 7 +------ src/llv8-constants.h | 1 - src/llv8-inl.h | 7 ------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index 2d6809af..487f3cd4 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -295,12 +295,7 @@ void String::Load() { kExternalStringTag = LoadConstant("ExternalStringTag"); kThinStringTag = LoadConstant("ThinStringTag"); - kLengthIsSmi = true; - kLengthOffset = LoadConstant("class_String__length__SMI"); - if (kLengthOffset == -1) { - kLengthIsSmi = false; - kLengthOffset = LoadConstant("class_String__length__int32_t"); - } + kLengthOffset = LoadConstant("class_String__length__int32_t"); } diff --git a/src/llv8-constants.h b/src/llv8-constants.h index 9387adcc..8394d6b1 100644 --- a/src/llv8-constants.h +++ b/src/llv8-constants.h @@ -266,7 +266,6 @@ class String : public Module { int64_t kThinStringTag; int64_t kLengthOffset; - bool kLengthIsSmi; protected: void Load(); diff --git a/src/llv8-inl.h b/src/llv8-inl.h index b8f11872..113bd9f7 100644 --- a/src/llv8-inl.h +++ b/src/llv8-inl.h @@ -470,13 +470,6 @@ inline int64_t String::Encoding(Error& err) { inline CheckedType String::Length(Error& err) { RETURN_IF_INVALID((*this), CheckedType()); - if (v8()->string()->kLengthIsSmi) { - Smi len = LoadFieldValue(v8()->string()->kLengthOffset, err); - RETURN_IF_INVALID(len, CheckedType()); - - return CheckedType(len.GetValue()); - } - CheckedType len = v8()->LoadValue>( LeaField(v8()->string()->kLengthOffset)); RETURN_IF_INVALID(len, CheckedType()); From 42015a09fefafe2e2b7b39f12ecac3d8dec29ea7 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:55:36 +0000 Subject: [PATCH 6/8] src: remove unused string postmortem constants --- src/llv8-constants.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index 487f3cd4..fefd6e87 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -312,22 +312,18 @@ void TwoByteString::Load() { void ConsString::Load() { - kFirstOffset = LoadConstant({"class_ConsString__first__String", - "class_ConsString__first_offset__int"}); - kSecondOffset = LoadConstant({"class_ConsString__second__String", - "class_ConsString__second_offset__int"}); + kFirstOffset = LoadConstant({"class_ConsString__first__String"}); + kSecondOffset = LoadConstant({"class_ConsString__second__String"}); } void SlicedString::Load() { kParentOffset = LoadConstant("class_SlicedString__parent__String"); - kOffsetOffset = LoadConstant({"class_SlicedString__offset__SMI", - "class_SlicedString__offset_offset__int"}); + kOffsetOffset = LoadConstant({"class_SlicedString__offset__SMI"}); } void ThinString::Load() { - kActualOffset = LoadConstant({"class_ThinString__actual__String", - "class_ThinString__actual_offset__int"}); + kActualOffset = LoadConstant({"class_ThinString__actual__String"}); } void FixedArrayBase::Load() { From 6ddafcb0319ac594bae14e59d8404969bd2f9eec Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:55:55 +0000 Subject: [PATCH 7/8] src: remove "neutered" fields for array buffers These are not present in any release lines. (ArrayBuffers are currently a little busted anyway, but that's a separate situation.) --- src/llv8-constants.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index fefd6e87..ce96dd19 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -379,17 +379,9 @@ void JSArrayBuffer::Load() { LoadConstant({"class_JSArrayBuffer__byte_length__Object", "class_JSArrayBuffer__byte_length__size_t"}); - if (kBackingStoreOffset.Check()) { - } - - kWasNeuteredMask = LoadConstant("jsarray_buffer_was_neutered_mask"); - kWasNeuteredShift = LoadConstant("jsarray_buffer_was_neutered_shift"); - - if (kWasNeuteredMask == -1) { - // TODO(indutny): check V8 version? - kWasNeuteredMask = 1 << 3; - kWasNeuteredShift = 3; - } + // TODO: This should use postmortem data. + kWasNeuteredMask = 1 << 3; + kWasNeuteredShift = 3; } From caf064620b968c8aef0feaea705028009c608b63 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 24 Sep 2022 05:56:16 +0000 Subject: [PATCH 8/8] src: remove kJSFrame Like the comment says, these were removed a long time ago. --- src/llv8-constants.cc | 2 -- src/llv8-constants.h | 1 - src/printer.cc | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/llv8-constants.cc b/src/llv8-constants.cc index ce96dd19..0e570543 100644 --- a/src/llv8-constants.cc +++ b/src/llv8-constants.cc @@ -519,8 +519,6 @@ void Frame::Load() { kExitFrame = LoadConstant("frametype_ExitFrame"); kInternalFrame = LoadConstant("frametype_InternalFrame"); kConstructFrame = LoadConstant("frametype_ConstructFrame"); - // NOTE: The JavaScript frame type was removed in V8 6.3.158. - kJSFrame = LoadConstant("frametype_JavaScriptFrame"); kOptimizedFrame = LoadConstant("frametype_OptimizedFrame"); kStubFrame = LoadConstant("frametype_StubFrame"); } diff --git a/src/llv8-constants.h b/src/llv8-constants.h index 8394d6b1..d1b928f7 100644 --- a/src/llv8-constants.h +++ b/src/llv8-constants.h @@ -495,7 +495,6 @@ class Frame : public Module { int64_t kExitFrame; int64_t kInternalFrame; int64_t kConstructFrame; - int64_t kJSFrame; int64_t kOptimizedFrame; int64_t kStubFrame; diff --git a/src/printer.cc b/src/printer.cc index 329392af..871e309f 100644 --- a/src/printer.cc +++ b/src/printer.cc @@ -49,8 +49,7 @@ std::string Printer::Stringify(v8::JSFrame js_frame, Error& err) { return ""; } else if (value == llv8_->frame()->kStubFrame) { return ""; - } else if (value != llv8_->frame()->kJSFrame && - value != llv8_->frame()->kOptimizedFrame) { + } else if (value != llv8_->frame()->kOptimizedFrame) { err = Error::Failure("Unknown frame marker %" PRId64, value); return std::string(); }