Commit 92c4588d authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[runtime] Cleanup SharedFunctionInfo fields definitions (2).

Store the rest raw data fields as ints.

Bug: v8:6470
Change-Id: I3d4ab56a722ed6c0b5cb30ecee2d94d7c8f07b40
Reviewed-on: https://chromium-review.googlesource.com/526638
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45775}
parent 62acc91a
......@@ -2979,12 +2979,12 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
__ ldr(scratch,
FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
int mask = 1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize);
int mask = 1 << (SharedFunctionInfo::kStrictModeBit);
__ tst(scratch, Operand(mask));
__ b(ne, &result_in_receiver);
// Do not transform the receiver to object for builtins.
__ tst(scratch, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
__ tst(scratch, Operand(1 << (SharedFunctionInfo::kNativeBit)));
__ b(ne, &result_in_receiver);
}
......
......@@ -2907,9 +2907,9 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
// Do not transform the receiver to object for builtins.
int32_t strict_mode_function_mask =
1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize);
int32_t native_mask = 1 << (SharedFunctionInfo::kNative + kSmiTagSize);
int32_t strict_mode_function_mask = 1
<< (SharedFunctionInfo::kStrictModeBit);
int32_t native_mask = 1 << (SharedFunctionInfo::kNativeBit);
__ And(scratch, scratch, Operand(strict_mode_function_mask | native_mask));
__ Branch(&result_in_receiver, ne, scratch, Operand(zero_reg));
}
......
......@@ -42,70 +42,19 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
INT_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
INT_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
kFormalParameterCountOffset)
#if V8_HOST_ARCH_32_BIT
SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
INT_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
kExpectedNofPropertiesOffset)
SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
INT_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
INT_ACCESSORS(SharedFunctionInfo, start_position_and_type,
kStartPositionAndTypeOffset)
SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
SMI_ACCESSORS(SharedFunctionInfo, function_token_position,
INT_ACCESSORS(SharedFunctionInfo, function_token_position,
kFunctionTokenPositionOffset)
SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, kCompilerHintsOffset)
SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason,
INT_ACCESSORS(SharedFunctionInfo, compiler_hints, kCompilerHintsOffset)
INT_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason,
kOptCountAndBailoutReasonOffset)
SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset)
SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset)
#else
#if V8_TARGET_LITTLE_ENDIAN
#define PSEUDO_SMI_LO_ALIGN 0
#define PSEUDO_SMI_HI_ALIGN kIntSize
#else
#define PSEUDO_SMI_LO_ALIGN kIntSize
#define PSEUDO_SMI_HI_ALIGN 0
#endif
#define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \
STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_LO_ALIGN); \
int holder::name() const { \
int value = READ_INT_FIELD(this, offset); \
DCHECK(kHeapObjectTag == 1); \
DCHECK((value & kHeapObjectTag) == 0); \
return value >> 1; \
} \
void holder::set_##name(int value) { \
DCHECK(kHeapObjectTag == 1); \
DCHECK((value & 0xC0000000) == 0xC0000000 || (value & 0xC0000000) == 0x0); \
WRITE_INT_FIELD(this, offset, (value << 1) & ~kHeapObjectTag); \
}
#define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \
STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_HI_ALIGN); \
INT_ACCESSORS(holder, name, offset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, expected_nof_properties,
kExpectedNofPropertiesOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, end_position, kEndPositionOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, start_position_and_type,
kStartPositionAndTypeOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, function_token_position,
kFunctionTokenPositionOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, compiler_hints,
kCompilerHintsOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, opt_count_and_bailout_reason,
kOptCountAndBailoutReasonOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, counters, kCountersOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, profiler_ticks,
kProfilerTicksOffset)
#endif
INT_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset)
INT_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
INT_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset)
bool SharedFunctionInfo::has_shared_name() const {
return raw_name() != kNoSharedNameSentinel;
......@@ -147,15 +96,9 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo,
kMustUseIgnitionTurbo)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_asm_wasm_broken,
kIsAsmWasmBroken)
BOOL_GETTER(SharedFunctionInfo, compiler_hints, optimization_disabled,
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, optimization_disabled,
kOptimizationDisabled)
void SharedFunctionInfo::set_optimization_disabled(bool disable) {
set_compiler_hints(
BooleanBit::set(compiler_hints(), kOptimizationDisabled, disable));
}
LanguageMode SharedFunctionInfo::language_mode() {
STATIC_ASSERT(LANGUAGE_END == 2);
return construct_language_mode(
......
......@@ -471,91 +471,27 @@ class SharedFunctionInfo : public HeapObject {
static const int kLastPointerFieldOffset = kFunctionLiteralIdOffset;
#endif
// Raw data fields.
static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize;
static const int kFormalParameterCountOffset = kLengthOffset + kIntSize;
#if V8_HOST_ARCH_32_BIT
// Smi fields.
static const int kExpectedNofPropertiesOffset =
kFormalParameterCountOffset + kPointerSize;
static const int kNumLiteralsOffset =
kExpectedNofPropertiesOffset + kPointerSize;
static const int kStartPositionAndTypeOffset =
kNumLiteralsOffset + kPointerSize;
static const int kEndPositionOffset =
kStartPositionAndTypeOffset + kPointerSize;
static const int kFunctionTokenPositionOffset =
kEndPositionOffset + kPointerSize;
static const int kCompilerHintsOffset =
kFunctionTokenPositionOffset + kPointerSize;
static const int kOptCountAndBailoutReasonOffset =
kCompilerHintsOffset + kPointerSize;
static const int kCountersOffset =
kOptCountAndBailoutReasonOffset + kPointerSize;
static const int kAstNodeCountOffset = kCountersOffset + kPointerSize;
static const int kProfilerTicksOffset = kAstNodeCountOffset + kPointerSize;
// Total size.
static const int kSize = kProfilerTicksOffset + kPointerSize;
#else
// The only reason to use smi fields instead of int fields is to allow
// iteration without maps decoding during garbage collections.
// To avoid wasting space on 64-bit architectures we use the following trick:
// we group integer fields into pairs
// The least significant integer in each pair is shifted left by 1. By doing
// this we guarantee that LSB of each kPointerSize aligned word is not set and
// thus this word cannot be treated as pointer to HeapObject during old space
// traversal.
#if V8_TARGET_LITTLE_ENDIAN
static const int kExpectedNofPropertiesOffset =
kFormalParameterCountOffset + kIntSize;
// TODO(ishell): Drop this unused field.
static const int kNumLiteralsOffset = kExpectedNofPropertiesOffset + kIntSize;
static const int kEndPositionOffset = kNumLiteralsOffset + kIntSize;
static const int kStartPositionAndTypeOffset = kEndPositionOffset + kIntSize;
static const int kFunctionTokenPositionOffset =
kStartPositionAndTypeOffset + kIntSize;
static const int kStartPositionAndTypeOffset = kNumLiteralsOffset + kIntSize;
static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
static const int kCompilerHintsOffset =
kFunctionTokenPositionOffset + kIntSize;
static const int kOptCountAndBailoutReasonOffset =
kCompilerHintsOffset + kIntSize;
static const int kCountersOffset = kOptCountAndBailoutReasonOffset + kIntSize;
static const int kAstNodeCountOffset = kCountersOffset + kIntSize;
static const int kProfilerTicksOffset = kAstNodeCountOffset + kIntSize;
// Total size.
static const int kSize = kProfilerTicksOffset + kIntSize;
#elif V8_TARGET_BIG_ENDIAN
static const int kNumLiteralsOffset = kFormalParameterCountOffset + kIntSize;
static const int kExpectedNofPropertiesOffset = kNumLiteralsOffset + kIntSize;
static const int kStartPositionAndTypeOffset =
kExpectedNofPropertiesOffset + kIntSize;
static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
static const int kCompilerHintsOffset = kEndPositionOffset + kIntSize;
static const int kFunctionTokenPositionOffset =
kCompilerHintsOffset + kIntSize;
static const int kCountersOffset = kFunctionTokenPositionOffset + kIntSize;
static const int kOptCountAndBailoutReasonOffset = kCountersOffset + kIntSize;
static const int kProfilerTicksOffset =
kOptCountAndBailoutReasonOffset + kIntSize;
static const int kAstNodeCountOffset = kProfilerTicksOffset + kIntSize;
// Total size.
static const int kSize = kAstNodeCountOffset + kIntSize;
#else
#error Unknown byte ordering
#endif // Big endian
#endif // 64-bit
static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize);
typedef FixedBodyDescriptor<kCodeOffset,
......@@ -573,6 +509,7 @@ class SharedFunctionInfo : public HeapObject {
static const int kStartPositionShift = 2;
static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1);
// TODO(ishell): turn this into a set of BitFields.
// Bit positions in compiler_hints.
enum CompilerHints {
// byte 0
......@@ -631,36 +568,22 @@ class SharedFunctionInfo : public HeapObject {
inline int length() const;
#if V8_HOST_ARCH_32_BIT
// On 32 bit platforms, compiler hints is a smi.
static const int kCompilerHintsSmiTagSize = kSmiTagSize;
static const int kCompilerHintsSize = kPointerSize;
#else
// On 64 bit platforms, compiler hints is not a smi, see comment above.
static const int kCompilerHintsSmiTagSize = 0;
static const int kCompilerHintsSize = kIntSize;
#endif
STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount +
SharedFunctionInfo::kCompilerHintsSmiTagSize <=
STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <=
SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte);
public:
// Constants for optimizing codegen for strict mode function and
// native tests when using integer-width instructions.
static const int kStrictModeBit =
kStrictModeFunction + kCompilerHintsSmiTagSize;
static const int kNativeBit = kNative + kCompilerHintsSmiTagSize;
static const int kHasDuplicateParametersBit =
kHasDuplicateParameters + kCompilerHintsSmiTagSize;
static const int kStrictModeBit = kStrictModeFunction;
static const int kNativeBit = kNative;
static const int kHasDuplicateParametersBit = kHasDuplicateParameters;
static const int kFunctionKindShift =
kFunctionKind + kCompilerHintsSmiTagSize;
static const int kAllFunctionKindBitsMask = FunctionKindBits::kMask
<< kCompilerHintsSmiTagSize;
static const int kFunctionKindShift = kFunctionKind;
static const int kAllFunctionKindBitsMask = FunctionKindBits::kMask;
static const int kMarkedForTierUpBit =
kMarkedForTierUp + kCompilerHintsSmiTagSize;
static const int kMarkedForTierUpBit = kMarkedForTierUp;
// Constants for optimizing codegen for strict mode function and
// native tests.
......@@ -671,11 +594,11 @@ class SharedFunctionInfo : public HeapObject {
kHasDuplicateParametersBit % kBitsPerByte;
static const int kClassConstructorBitsWithinByte =
FunctionKind::kClassConstructor << kCompilerHintsSmiTagSize;
FunctionKind::kClassConstructor;
STATIC_ASSERT(kClassConstructorBitsWithinByte < (1 << kBitsPerByte));
static const int kDerivedConstructorBitsWithinByte =
FunctionKind::kDerivedConstructor << kCompilerHintsSmiTagSize;
FunctionKind::kDerivedConstructor;
STATIC_ASSERT(kDerivedConstructorBitsWithinByte < (1 << kBitsPerByte));
static const int kMarkedForTierUpBitWithinByte =
......@@ -683,12 +606,11 @@ class SharedFunctionInfo : public HeapObject {
#if defined(V8_TARGET_LITTLE_ENDIAN)
#define BYTE_OFFSET(compiler_hint) \
kCompilerHintsOffset + \
(compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte
kCompilerHintsOffset + (compiler_hint) / kBitsPerByte
#elif defined(V8_TARGET_BIG_ENDIAN)
#define BYTE_OFFSET(compiler_hint) \
kCompilerHintsOffset + (kCompilerHintsSize - 1) - \
((compiler_hint + kCompilerHintsSmiTagSize) / kBitsPerByte)
((compiler_hint) / kBitsPerByte)
#else
#error Unknown byte ordering
#endif
......
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