OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 Code::Flags flags, const char* name); | 39 Code::Flags flags, const char* name); |
40 | 40 |
41 enum AllocationFlag : uint8_t { | 41 enum AllocationFlag : uint8_t { |
42 kNone = 0, | 42 kNone = 0, |
43 kDoubleAlignment = 1, | 43 kDoubleAlignment = 1, |
44 kPretenured = 1 << 1 | 44 kPretenured = 1 << 1 |
45 }; | 45 }; |
46 | 46 |
47 typedef base::Flags<AllocationFlag> AllocationFlags; | 47 typedef base::Flags<AllocationFlag> AllocationFlags; |
48 | 48 |
| 49 // TODO(ishell): Fix all loads/stores from arrays by int32 offsets/indices |
| 50 // and eventually remove INTEGER_PARAMETERS in favour of INTPTR_PARAMETERS. |
49 enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS, INTPTR_PARAMETERS }; | 51 enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS, INTPTR_PARAMETERS }; |
50 | 52 |
| 53 // On 32-bit platforms, there is a slight performance advantage to doing all |
| 54 // of the array offset/index arithmetic with SMIs, since it's possible |
| 55 // to save a few tag/untag operations without paying an extra expense when |
| 56 // calculating array offset (the smi math can be folded away) and there are |
| 57 // fewer live ranges. Thus only convert indices to untagged value on 64-bit |
| 58 // platforms. |
| 59 ParameterMode OptimalParameterMode() const { |
| 60 return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS; |
| 61 } |
| 62 |
| 63 compiler::Node* UntagParameter(compiler::Node* value, ParameterMode mode) { |
| 64 if (mode != SMI_PARAMETERS) value = SmiUntag(value); |
| 65 return value; |
| 66 } |
| 67 |
| 68 compiler::Node* TagParameter(compiler::Node* value, ParameterMode mode) { |
| 69 if (mode != SMI_PARAMETERS) value = SmiTag(value); |
| 70 return value; |
| 71 } |
| 72 |
51 compiler::Node* BooleanMapConstant(); | 73 compiler::Node* BooleanMapConstant(); |
52 compiler::Node* EmptyStringConstant(); | 74 compiler::Node* EmptyStringConstant(); |
53 compiler::Node* HeapNumberMapConstant(); | 75 compiler::Node* HeapNumberMapConstant(); |
54 compiler::Node* NoContextConstant(); | 76 compiler::Node* NoContextConstant(); |
55 compiler::Node* NanConstant(); | 77 compiler::Node* NanConstant(); |
56 compiler::Node* NullConstant(); | 78 compiler::Node* NullConstant(); |
57 compiler::Node* MinusZeroConstant(); | 79 compiler::Node* MinusZeroConstant(); |
58 compiler::Node* UndefinedConstant(); | 80 compiler::Node* UndefinedConstant(); |
59 compiler::Node* TheHoleConstant(); | 81 compiler::Node* TheHoleConstant(); |
60 compiler::Node* HashSeed(); | 82 compiler::Node* HashSeed(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 Label* if_hash_not_computed = nullptr); | 241 Label* if_hash_not_computed = nullptr); |
220 | 242 |
221 // Load length field of a String object. | 243 // Load length field of a String object. |
222 compiler::Node* LoadStringLength(compiler::Node* object); | 244 compiler::Node* LoadStringLength(compiler::Node* object); |
223 // Load value field of a JSValue object. | 245 // Load value field of a JSValue object. |
224 compiler::Node* LoadJSValueValue(compiler::Node* object); | 246 compiler::Node* LoadJSValueValue(compiler::Node* object); |
225 // Load value field of a WeakCell object. | 247 // Load value field of a WeakCell object. |
226 compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell, | 248 compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell, |
227 Label* if_cleared = nullptr); | 249 Label* if_cleared = nullptr); |
228 | 250 |
229 compiler::Node* AllocateUninitializedFixedArray(compiler::Node* length); | |
230 | |
231 // Load an array element from a FixedArray. | 251 // Load an array element from a FixedArray. |
232 compiler::Node* LoadFixedArrayElement( | 252 compiler::Node* LoadFixedArrayElement( |
233 compiler::Node* object, compiler::Node* int32_index, | 253 compiler::Node* object, compiler::Node* int32_index, |
234 int additional_offset = 0, | 254 int additional_offset = 0, |
235 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 255 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
236 // Load an array element from a FixedArray, untag it and return it as Word32. | 256 // Load an array element from a FixedArray, untag it and return it as Word32. |
237 compiler::Node* LoadAndUntagToWord32FixedArrayElement( | 257 compiler::Node* LoadAndUntagToWord32FixedArrayElement( |
238 compiler::Node* object, compiler::Node* int32_index, | 258 compiler::Node* object, compiler::Node* int32_index, |
239 int additional_offset = 0, | 259 int additional_offset = 0, |
240 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 260 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 compiler::Node* SmiShiftBitsConstant(); | 634 compiler::Node* SmiShiftBitsConstant(); |
615 | 635 |
616 static const int kElementLoopUnrollThreshold = 8; | 636 static const int kElementLoopUnrollThreshold = 8; |
617 }; | 637 }; |
618 | 638 |
619 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 639 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
620 | 640 |
621 } // namespace internal | 641 } // namespace internal |
622 } // namespace v8 | 642 } // namespace v8 |
623 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 643 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |