Source/JavaScriptCore/ChangeLog

 12021-08-25 Commit Queue <commit-queue@webkit.org>
 2
 3 Unreviewed, reverting r281523.
 4 https://bugs.webkit.org/show_bug.cgi?id=229494
 5
 6 broke cloop build
 7
 8 Reverted changeset:
 9
 10 "Add for-in OwnStructureMode optimizations to LLInt"
 11 https://bugs.webkit.org/show_bug.cgi?id=229038
 12 https://commits.webkit.org/r281523
 13
1142021-08-24 Mark Lam <mark.lam@apple.com>
215
316 Refactor ENABLE(JIT_OPERATION_VALIDATION) code to emit no code when disabled.

Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

@@void SpeculativeJIT::compileEnumeratorGetByVal(Node* node)
1364713647 m_jit.signExtend32ToPtr(scratchGPR, scratchGPR);
1364813648 if (!haveStorage)
1364913649 m_jit.loadPtr(MacroAssembler::Address(baseCellGPR, JSObject::butterflyOffset()), storageGPR);
13650  constexpr intptr_t offsetOfFirstProperty = offsetInButterfly(firstOutOfLineOffset) * static_cast<intptr_t>(sizeof(EncodedJSValue));
 13650 int32_t offsetOfFirstProperty = static_cast<int32_t>(offsetInButterfly(firstOutOfLineOffset)) * sizeof(EncodedJSValue);
1365113651 m_jit.loadValue(MacroAssembler::BaseIndex(storageGPR, scratchGPR, MacroAssembler::TimesEight, offsetOfFirstProperty), resultRegs);
1365213652 doneCases.append(m_jit.jump());
1365313653 }

Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

@@private:
1325813258
1325913259 LValue realIndex = m_out.signExt32To64(
1326013260 m_out.neg(m_out.sub(index, inlineCapacity)));
13261  constexpr intptr_t offsetOfFirstProperty = offsetInButterfly(firstOutOfLineOffset) * static_cast<intptr_t>(sizeof(EncodedJSValue));
 13261 int32_t offsetOfFirstProperty = static_cast<int32_t>(offsetInButterfly(firstOutOfLineOffset)) * sizeof(EncodedJSValue);
1326213262 results.append(m_out.anchor(
1326313263 m_out.load64(m_out.baseIndex(m_heaps.properties.atAnyNumber(), storage, realIndex, ScaleEight, offsetOfFirstProperty))));
1326413264 m_out.jump(continuation);

Source/JavaScriptCore/jit/JITPropertyAccess.cpp

@@void JIT::emit_op_enumerator_get_by_val(const Instruction* currentInstruction)
30893089 sub32(Address(regT2, JSPropertyNameEnumerator::cachedInlineCapacityOffset()), regT3);
30903090 neg32(regT3);
30913091 signExtend32ToPtr(regT3, regT3);
3092  constexpr intptr_t offsetOfFirstProperty = offsetInButterfly(firstOutOfLineOffset) * static_cast<intptr_t>(sizeof(EncodedJSValue));
 3092 int32_t offsetOfFirstProperty = static_cast<int32_t>(offsetInButterfly(firstOutOfLineOffset)) * sizeof(EncodedJSValue);
30933093 load64(BaseIndex(regT0, regT3, TimesEight, offsetOfFirstProperty), resultGPR);
30943094 doneCases.append(jump());
30953095

Source/JavaScriptCore/llint/LowLevelInterpreter.asm

@@slowPathOp(define_accessor_property)
19941994slowPathOp(define_data_property)
19951995slowPathOp(get_by_val_with_this)
19961996slowPathOp(get_property_enumerator)
 1997slowPathOp(enumerator_next)
 1998slowPathOp(enumerator_get_by_val)
 1999slowPathOp(enumerator_in_by_val)
 2000slowPathOp(enumerator_has_own_property)
19972001
19982002if not JSVALUE64
19992003 slowPathOp(get_prototype_of)

Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

@@llintOpWithMetadata(op_set_private_brand, OpSetPrivateBrand, macro (size, get, d
30793079 dispatch()
30803080end)
30813081
3082 slowPathOp(enumerator_next)
3083 slowPathOp(enumerator_get_by_val)
3084 slowPathOp(enumerator_in_by_val)
3085 slowPathOp(enumerator_has_own_property)

Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

@@macro loadVariable(get, fieldName, valueReg)
534534 loadq [cfr, valueReg, 8], valueReg
535535end
536536
537 macro storeVariable(get, fieldName, newValueReg, scratchReg)
538  get(fieldName, scratchReg)
539  storeq newValueReg, [cfr, scratchReg, 8]
540 end
541 
542537# Index and value must be different registers. Index may be clobbered.
543538macro loadConstant(size, index, value)
544539 macro loadNarrow()

@@llintOpWithMetadata(op_iterator_next, OpIteratorNext, macro (size, get, dispatch
30783073.notDone:
30793074 macro storeValueAndDispatch(v)
30803075 move v, t2
3081  storeVariable(get, m_value, t2, t1)
 3076 get(m_value, t1)
 3077 storeq t2, [cfr, t1, 8]
30823078 checkStackPointerAlignment(t0, 0xbaddb01e)
30833079 dispatch()
30843080 end

@@llintOpWithMetadata(op_iterator_next, OpIteratorNext, macro (size, get, dispatch
30933089 dispatch()
30943090end)
30953091
3096 llintOp(op_enumerator_next, OpEnumeratorNext, macro (size, get, dispatch)
3097  # Note: this will always call the slow path on at least the first/last execution of EnumeratorNext for any given loop.
3098  # The upside this is that we don't have to record any metadata or mode information here as the slow path will do it for us when transitioning from InitMode/IndexedMode to OwnStructureMode, or from OwnStructureMode to GenericMode.
3099  get(m_mode, t0)
3100  bbneq t0, constexpr JSPropertyNameEnumerator::OwnStructureMode, .nextSlowPath
3101 
3102  get(m_base, t1)
3103  loadConstantOrVariableCell(size, t1, t0, .nextSlowPath)
3104 
3105  loadVariable(get, m_enumerator, t1)
3106  loadi JSPropertyNameEnumerator::m_cachedStructureID[t1], t2
3107  bineq t2, JSCell::m_structureID[t0], .nextSlowPath
3108 
3109  loadVariable(get, m_index, t2)
3110  addq 1, t2
3111  loadi JSPropertyNameEnumerator::m_endStructurePropertyIndex, t3
3112  biaeq t2, t3, .nextSlowPath
3113 
3114  storeVariable(get, m_index, t2, t3)
3115  loadp JSPropertyNameEnumerator::m_propertyNames[t1], t3
3116  zxi2q t2, t2
3117  loadp [t3, t2, PtrSize], t3
3118 
3119  storeVariable(get, m_propertyName, t3, t2)
3120  dispatch()
3121 
3122 .nextSlowPath:
3123  callSlowPath(_slow_path_enumerator_next)
3124  dispatch()
3125 end)
3126 
3127 llintOpWithMetadata(op_enumerator_get_by_val, OpEnumeratorGetByVal, macro (size, get, dispatch, metadata, return)
3128  metadata(t5, t0)
3129 
3130  loadVariable(get, m_mode, t0)
3131 
3132  # FIXME: This should be orb but that doesn't exist for some reason... https://bugs.webkit.org/show_bug.cgi?id=229445
3133  loadb OpEnumeratorGetByVal::Metadata::m_enumeratorMetadata[t5], t1
3134  ori t0, t1
3135  storeb t1, OpEnumeratorGetByVal::Metadata::m_enumeratorMetadata[t5]
3136 
3137  bbneq t0, constexpr JSPropertyNameEnumerator::OwnStructureMode, .getSlowPath
3138 
3139  get(m_base, t1)
3140  loadConstantOrVariableCell(size, t1, t0, .getSlowPath)
3141 
3142  loadVariable(get, m_enumerator, t1)
3143  loadi JSPropertyNameEnumerator::m_cachedStructureID[t1], t2
3144  bineq t2, JSCell::m_structureID[t0], .getSlowPath
3145 
3146  loadVariable(get, m_index, t2)
3147  loadi JSPropertyNameEnumerator::m_cachedInlineCapacity[t1], t1
3148  biaeq t2, t1, .outOfLine
3149 
3150  zxi2q t2, t2
3151  loadq sizeof JSObject[t0, t2, 8], t2
3152  jmp .done
3153 
3154 .outOfLine:
3155  loadp JSObject::m_butterfly[t0], t0
3156  subi t1, t2
3157  negi t2
3158  sxi2q t2, t2
3159  loadq constexpr ((offsetInButterfly(firstOutOfLineOffset)) * sizeof(EncodedJSValue))[t0, t2, 8], t2
3160 
3161 .done:
3162  valueProfile(OpEnumeratorGetByVal, m_profile, t5, t2)
3163  return(t2)
3164 
3165 .getSlowPath:
3166  callSlowPath(_slow_path_enumerator_get_by_val)
3167  dispatch()
3168 end)
3169 
3170 macro hasPropertyImpl(opcodeStruct, size, get, dispatch, metadata, return, slowPath)
3171  metadata(t5, t0)
3172 
3173  loadVariable(get, m_mode, t0)
3174  # FIXME: This should be orb but that doesn't exist for some reason... https://bugs.webkit.org/show_bug.cgi?id=229445
3175  loadb %opcodeStruct%::Metadata::m_enumeratorMetadata[t5], t1
3176  ori t0, t1
3177  storeb t1, %opcodeStruct%::Metadata::m_enumeratorMetadata[t5]
3178 
3179  bbneq t0, constexpr JSPropertyNameEnumerator::OwnStructureMode, .callSlowPath
3180 
3181  get(m_base, t1)
3182  loadConstantOrVariableCell(size, t1, t0, .callSlowPath)
3183 
3184  loadVariable(get, m_enumerator, t1)
3185  loadi JSPropertyNameEnumerator::m_cachedStructureID[t1], t2
3186  bineq t2, JSCell::m_structureID[t0], .callSlowPath
3187 
3188  move ValueTrue, t2
3189  return(t2)
3190 
3191 .callSlowPath:
3192  callSlowPath(slowPath)
3193  dispatch()
3194 end
3195 
3196 llintOpWithMetadata(op_enumerator_in_by_val, OpEnumeratorInByVal, macro (size, get, dispatch, metadata, return)
3197  hasPropertyImpl(OpEnumeratorInByVal, size, get, dispatch, metadata, return, _slow_path_enumerator_in_by_val)
3198 end)
3199 
3200 llintOpWithMetadata(op_enumerator_has_own_property, OpEnumeratorHasOwnProperty, macro (size, get, dispatch, metadata, return)
3201  hasPropertyImpl(OpEnumeratorHasOwnProperty, size, get, dispatch, metadata, return, _slow_path_enumerator_has_own_property)
3202 end)
32033092
32043093llintOpWithProfile(op_get_internal_field, OpGetInternalField, macro (size, get, dispatch, return)
32053094 loadVariable(get, m_base, t1)

Source/JavaScriptCore/offlineasm/arm64.rb

@@class Instruction
884884 when "move"
885885 if operands[0].immediate?
886886 emitARM64MoveImmediate(operands[0].value, operands[1])
887  elsif operands[0] != operands[1]
 887 else
888888 emitARM64("mov", operands, :quad)
889889 end
890890 when "moved"

Source/JavaScriptCore/offlineasm/generate_offset_extractor.rb

@@File.open(outputFlnm, "w") {
9292 constsList = constsList(lowLevelAST)
9393
9494 emitCodeInConfiguration(concreteSettings, lowLevelAST, backend) {
95 
96  # Windows complains about signed integers being cast to unsigned but we just want the bits.
97  outp.puts "\#if COMPILER(MSVC)"
98  outp.puts "\#pragma warning(disable:4308)"
99  outp.puts "\#endif"
10095 constsList.each_with_index {
10196 | const, index |
10297 outp.puts "constexpr int64_t constValue#{index} = static_cast<int64_t>(#{const.value});"

Source/JavaScriptCore/runtime/Butterfly.h

@@public:
209209 }
210210
211211 static ptrdiff_t offsetOfPropertyStorage() { return -static_cast<ptrdiff_t>(sizeof(IndexingHeader)); }
212  constexpr static int indexOfPropertyStorage()
 212 static int indexOfPropertyStorage()
213213 {
214214 ASSERT(sizeof(IndexingHeader) == sizeof(EncodedJSValue));
215215 return -1;

Source/JavaScriptCore/runtime/JSObject.h

@@inline bool JSObject::putDirect(VM& vm, PropertyName propertyName, JSValue value
15641564 return putDirectInternal<PutModeDefineOwnProperty>(vm, propertyName, value, 0, slot);
15651565}
15661566
1567 constexpr inline intptr_t offsetInButterfly(PropertyOffset offset)
 1567inline size_t offsetInButterfly(PropertyOffset offset)
15681568{
15691569 return offsetInOutOfLineStorage(offset) + Butterfly::indexOfPropertyStorage();
15701570}

Source/JavaScriptCore/runtime/PropertyOffset.h

@@static constexpr PropertyOffset knownPolyProtoOffset = 0;
3737static_assert(knownPolyProtoOffset < firstOutOfLineOffset, "We assume in all the JITs that the poly proto offset is an inline offset");
3838
3939// Declare all of the functions because they tend to do forward calls.
40 constexpr inline void checkOffset(PropertyOffset);
41 constexpr inline void checkOffset(PropertyOffset, int inlineCapacity);
42 constexpr inline void validateOffset(PropertyOffset);
43 constexpr inline void validateOffset(PropertyOffset, int inlineCapacity);
44 constexpr inline bool isValidOffset(PropertyOffset);
45 constexpr inline bool isInlineOffset(PropertyOffset);
46 constexpr inline bool isOutOfLineOffset(PropertyOffset);
47 constexpr inline intptr_t offsetInInlineStorage(PropertyOffset);
48 constexpr inline intptr_t offsetInOutOfLineStorage(PropertyOffset);
49 constexpr inline intptr_t offsetInRespectiveStorage(PropertyOffset);
50 constexpr inline size_t numberOfOutOfLineSlotsForMaxOffset(PropertyOffset);
51 constexpr inline size_t numberOfSlotsForMaxOffset(PropertyOffset, int inlineCapacity);
52 
53 constexpr inline void checkOffset(PropertyOffset offset)
 40inline void checkOffset(PropertyOffset);
 41inline void checkOffset(PropertyOffset, int inlineCapacity);
 42inline void validateOffset(PropertyOffset);
 43inline void validateOffset(PropertyOffset, int inlineCapacity);
 44inline bool isValidOffset(PropertyOffset);
 45inline bool isInlineOffset(PropertyOffset);
 46inline bool isOutOfLineOffset(PropertyOffset);
 47inline size_t offsetInInlineStorage(PropertyOffset);
 48inline size_t offsetInOutOfLineStorage(PropertyOffset);
 49inline size_t offsetInRespectiveStorage(PropertyOffset);
 50inline size_t numberOfOutOfLineSlotsForMaxOffset(PropertyOffset);
 51inline size_t numberOfSlotsForMaxOffset(PropertyOffset, int inlineCapacity);
 52
 53inline void checkOffset(PropertyOffset offset)
5454{
5555 UNUSED_PARAM(offset);
5656 ASSERT(offset >= invalidOffset);
5757}
5858
59 constexpr inline void checkOffset(PropertyOffset offset, int inlineCapacity)
 59inline void checkOffset(PropertyOffset offset, int inlineCapacity)
6060{
6161 UNUSED_PARAM(offset);
6262 UNUSED_PARAM(inlineCapacity);

@@constexpr inline void checkOffset(PropertyOffset offset, int inlineCapacity)
6666 || isOutOfLineOffset(offset));
6767}
6868
69 constexpr inline void validateOffset(PropertyOffset offset)
 69inline void validateOffset(PropertyOffset offset)
7070{
7171 checkOffset(offset);
7272 ASSERT(isValidOffset(offset));
7373}
7474
75 constexpr inline void validateOffset(PropertyOffset offset, int inlineCapacity)
 75inline void validateOffset(PropertyOffset offset, int inlineCapacity)
7676{
7777 checkOffset(offset, inlineCapacity);
7878 ASSERT(isValidOffset(offset));
7979}
8080
81 constexpr inline bool isValidOffset(PropertyOffset offset)
 81inline bool isValidOffset(PropertyOffset offset)
8282{
8383 checkOffset(offset);
8484 return offset != invalidOffset;
8585}
8686
87 constexpr inline bool isInlineOffset(PropertyOffset offset)
 87inline bool isInlineOffset(PropertyOffset offset)
8888{
8989 checkOffset(offset);
9090 return offset < firstOutOfLineOffset;
9191}
9292
93 constexpr inline bool isOutOfLineOffset(PropertyOffset offset)
 93inline bool isOutOfLineOffset(PropertyOffset offset)
9494{
9595 checkOffset(offset);
9696 return !isInlineOffset(offset);
9797}
9898
99 constexpr inline intptr_t offsetInInlineStorage(PropertyOffset offset)
 99inline size_t offsetInInlineStorage(PropertyOffset offset)
100100{
101101 validateOffset(offset);
102102 ASSERT(isInlineOffset(offset));
103103 return offset;
104104}
105105
106 constexpr inline intptr_t offsetInOutOfLineStorage(PropertyOffset offset)
 106inline size_t offsetInOutOfLineStorage(PropertyOffset offset)
107107{
108108 validateOffset(offset);
109109 ASSERT(isOutOfLineOffset(offset));
110110 return -static_cast<ptrdiff_t>(offset - firstOutOfLineOffset) - 1;
111111}
112112
113 constexpr inline intptr_t offsetInRespectiveStorage(PropertyOffset offset)
 113inline size_t offsetInRespectiveStorage(PropertyOffset offset)
114114{
115115 if (isInlineOffset(offset))
116116 return offsetInInlineStorage(offset);
117117 return offsetInOutOfLineStorage(offset);
118118}
119119
120 constexpr inline size_t numberOfOutOfLineSlotsForMaxOffset(PropertyOffset offset)
 120inline size_t numberOfOutOfLineSlotsForMaxOffset(PropertyOffset offset)
121121{
122122 checkOffset(offset);
123123 if (offset < firstOutOfLineOffset)

@@constexpr inline size_t numberOfOutOfLineSlotsForMaxOffset(PropertyOffset offset
125125 return offset - firstOutOfLineOffset + 1;
126126}
127127
128 constexpr inline size_t numberOfSlotsForMaxOffset(PropertyOffset offset, int inlineCapacity)
 128inline size_t numberOfSlotsForMaxOffset(PropertyOffset offset, int inlineCapacity)
129129{
130130 checkOffset(offset, inlineCapacity);
131131 if (offset < inlineCapacity)

@@constexpr inline size_t numberOfSlotsForMaxOffset(PropertyOffset offset, int inl
133133 return inlineCapacity + numberOfOutOfLineSlotsForMaxOffset(offset);
134134}
135135
136 constexpr inline PropertyOffset offsetForPropertyNumber(int propertyNumber, int inlineCapacity)
 136inline PropertyOffset offsetForPropertyNumber(int propertyNumber, int inlineCapacity)
137137{
138138 PropertyOffset offset = propertyNumber;
139139 if (offset >= inlineCapacity) {