OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
| 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
| 7 |
| 8 #include "src/compiler/code-assembler.h" |
| 9 #include "src/objects.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 class CallInterfaceDescriptor; |
| 15 |
| 16 // Provides JavaScript-specific "macro-assembler" functionality on top of the |
| 17 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |
| 18 // it's possible to add JavaScript-specific useful CodeAssembler "macros" |
| 19 // without modifying files in the compiler directory (and requiring a review |
| 20 // from a compiler directory OWNER). |
| 21 class CodeStubAssembler : public compiler::CodeAssembler { |
| 22 public: |
| 23 // Create with CallStub linkage. |
| 24 // |result_size| specifies the number of results returned by the stub. |
| 25 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
| 26 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 27 const CallInterfaceDescriptor& descriptor, |
| 28 Code::Flags flags, const char* name, |
| 29 size_t result_size = 1); |
| 30 |
| 31 // Create with JSCall linkage. |
| 32 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, |
| 33 Code::Flags flags, const char* name); |
| 34 |
| 35 // Smi conversions. |
| 36 compiler::Node* SmiToFloat64(compiler::Node* value); |
| 37 compiler::Node* SmiToWord32(compiler::Node* value); |
| 38 |
| 39 // Smi operations. |
| 40 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); |
| 41 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); |
| 42 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); |
| 43 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); |
| 44 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); |
| 45 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); |
| 46 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); |
| 47 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
| 48 |
| 49 // Check a value for smi-ness |
| 50 compiler::Node* WordIsSmi(compiler::Node* a); |
| 51 |
| 52 // Check that the value is a positive smi. |
| 53 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
| 54 |
| 55 // Load an object pointer from a buffer that isn't in the heap. |
| 56 compiler::Node* LoadBufferObject(compiler::Node* buffer, int offset, |
| 57 MachineType rep = MachineType::AnyTagged()); |
| 58 // Load a field from an object on the heap. |
| 59 compiler::Node* LoadObjectField(compiler::Node* object, int offset, |
| 60 MachineType rep = MachineType::AnyTagged()); |
| 61 // Load the floating point value of a HeapNumber. |
| 62 compiler::Node* LoadHeapNumberValue(compiler::Node* object); |
| 63 // Store the floating point value of a HeapNumber. |
| 64 |
| 65 // Load the Map of an HeapObject. |
| 66 compiler::Node* LoadMap(compiler::Node* object); |
| 67 // Load the instance type of an HeapObject. |
| 68 compiler::Node* LoadInstanceType(compiler::Node* object); |
| 69 |
| 70 // Load the elements backing store of a JSObject. |
| 71 compiler::Node* LoadElements(compiler::Node* object); |
| 72 // Load the length of a fixed array base instance. |
| 73 compiler::Node* LoadFixedArrayBaseLength(compiler::Node* array); |
| 74 |
| 75 // Load the bit field of a Map. |
| 76 compiler::Node* LoadMapBitField(compiler::Node* map); |
| 77 // Load bit field 2 of a map. |
| 78 compiler::Node* LoadMapBitField2(compiler::Node* map); |
| 79 // Load bit field 3 of a map. |
| 80 compiler::Node* LoadMapBitField3(compiler::Node* map); |
| 81 // Load the instance type of a map. |
| 82 compiler::Node* LoadMapInstanceType(compiler::Node* map); |
| 83 // Load the instance descriptors of a map. |
| 84 compiler::Node* LoadMapDescriptors(compiler::Node* map); |
| 85 |
| 86 // Load the hash field of a name. |
| 87 compiler::Node* LoadNameHash(compiler::Node* name); |
| 88 |
| 89 // Load an array element from a FixedArray. |
| 90 compiler::Node* LoadFixedArrayElementInt32Index(compiler::Node* object, |
| 91 compiler::Node* int32_index, |
| 92 int additional_offset = 0); |
| 93 compiler::Node* LoadFixedArrayElementSmiIndex(compiler::Node* object, |
| 94 compiler::Node* smi_index, |
| 95 int additional_offset = 0); |
| 96 compiler::Node* LoadFixedArrayElementConstantIndex(compiler::Node* object, |
| 97 int index); |
| 98 |
| 99 compiler::Node* StoreHeapNumberValue(compiler::Node* object, |
| 100 compiler::Node* value); |
| 101 |
| 102 // Store the Map of an HeapObject. |
| 103 compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object, |
| 104 compiler::Node* map); |
| 105 // Store an array element to a FixedArray. |
| 106 compiler::Node* StoreFixedArrayElementNoWriteBarrier(compiler::Node* object, |
| 107 compiler::Node* index, |
| 108 compiler::Node* value); |
| 109 // Allocate a HeapNumber without initializing its value. |
| 110 compiler::Node* AllocateHeapNumber(); |
| 111 // Allocate a HeapNumber with a specific value. |
| 112 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value); |
| 113 |
| 114 // Returns a node that is true if the given bit is set in |word32|. |
| 115 template <typename T> |
| 116 compiler::Node* BitFieldDecode(compiler::Node* word32) { |
| 117 return BitFieldDecode(word32, T::kShift, T::kMask); |
| 118 } |
| 119 |
| 120 compiler::Node* BitFieldDecode(compiler::Node* word32, uint32_t shift, |
| 121 uint32_t mask); |
| 122 |
| 123 // Conversions. |
| 124 compiler::Node* ChangeFloat64ToTagged(compiler::Node* value); |
| 125 compiler::Node* ChangeInt32ToTagged(compiler::Node* value); |
| 126 compiler::Node* TruncateTaggedToFloat64(compiler::Node* context, |
| 127 compiler::Node* value); |
| 128 compiler::Node* TruncateTaggedToWord32(compiler::Node* context, |
| 129 compiler::Node* value); |
| 130 // Truncate the floating point value of a HeapNumber to an Int32. |
| 131 compiler::Node* TruncateHeapNumberValueToWord32(compiler::Node* object); |
| 132 |
| 133 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, |
| 134 Label* if_false) { |
| 135 BranchIf(SmiLessThan(a, b), if_true, if_false); |
| 136 } |
| 137 |
| 138 void BranchIfSmiLessThanOrEqual(compiler::Node* a, compiler::Node* b, |
| 139 Label* if_true, Label* if_false) { |
| 140 BranchIf(SmiLessThanOrEqual(a, b), if_true, if_false); |
| 141 } |
| 142 }; |
| 143 |
| 144 } // namespace internal |
| 145 } // namespace v8 |
| 146 |
| 147 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |