Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 // Allocate an object of the given size. | 156 // Allocate an object of the given size. |
| 157 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); | 157 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
| 158 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); | 158 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
| 159 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); | 159 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
| 160 compiler::Node* InnerAllocate(compiler::Node* previous, | 160 compiler::Node* InnerAllocate(compiler::Node* previous, |
| 161 compiler::Node* offset); | 161 compiler::Node* offset); |
| 162 compiler::Node* IsRegularHeapObjectSize(compiler::Node* size); | 162 compiler::Node* IsRegularHeapObjectSize(compiler::Node* size); |
| 163 | 163 |
| 164 void Assert(compiler::Node* condition, const char* string = nullptr, | 164 void Assert(compiler::Node* condition, const char* string = nullptr, |
| 165 const char* file = nullptr, int line = 0); | 165 const char* file = nullptr, int line = 0); |
| 166 void SlowAssert(compiler::Node* condition, const char* string = nullptr, | |
|
Igor Sheludko
2016/10/26 13:24:27
See next comment.
| |
| 167 const char* file = nullptr, int line = 0); | |
| 166 | 168 |
| 167 // Check a value for smi-ness | 169 // Check a value for smi-ness |
| 168 compiler::Node* TaggedIsSmi(compiler::Node* a); | 170 compiler::Node* TaggedIsSmi(compiler::Node* a); |
| 169 // Check that the value is a non-negative smi. | 171 // Check that the value is a non-negative smi. |
| 170 compiler::Node* WordIsPositiveSmi(compiler::Node* a); | 172 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
| 171 // Check that a word has a word-aligned address. | 173 // Check that a word has a word-aligned address. |
| 172 compiler::Node* WordIsWordAligned(compiler::Node* word); | 174 compiler::Node* WordIsWordAligned(compiler::Node* word); |
| 173 compiler::Node* WordIsPowerOfTwo(compiler::Node* value); | 175 compiler::Node* WordIsPowerOfTwo(compiler::Node* value); |
| 174 | 176 |
| 175 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, | 177 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 203 void BranchIfSimd128Equal(compiler::Node* lhs, compiler::Node* rhs, | 205 void BranchIfSimd128Equal(compiler::Node* lhs, compiler::Node* rhs, |
| 204 Label* if_equal, Label* if_notequal) { | 206 Label* if_equal, Label* if_notequal) { |
| 205 BranchIfSimd128Equal(lhs, LoadMap(lhs), rhs, LoadMap(rhs), if_equal, | 207 BranchIfSimd128Equal(lhs, LoadMap(lhs), rhs, LoadMap(rhs), if_equal, |
| 206 if_notequal); | 208 if_notequal); |
| 207 } | 209 } |
| 208 | 210 |
| 209 void BranchIfJSReceiver(compiler::Node* object, Label* if_true, | 211 void BranchIfJSReceiver(compiler::Node* object, Label* if_true, |
| 210 Label* if_false); | 212 Label* if_false); |
| 211 void BranchIfJSObject(compiler::Node* object, Label* if_true, | 213 void BranchIfJSObject(compiler::Node* object, Label* if_true, |
| 212 Label* if_false); | 214 Label* if_false); |
| 213 | |
| 214 void BranchIfFastJSArray(compiler::Node* object, compiler::Node* context, | 215 void BranchIfFastJSArray(compiler::Node* object, compiler::Node* context, |
| 215 Label* if_true, Label* if_false); | 216 Label* if_true, Label* if_false); |
| 216 | 217 |
| 217 // Load value from current frame by given offset in bytes. | 218 // Load value from current frame by given offset in bytes. |
| 218 compiler::Node* LoadFromFrame(int offset, | 219 compiler::Node* LoadFromFrame(int offset, |
| 219 MachineType rep = MachineType::AnyTagged()); | 220 MachineType rep = MachineType::AnyTagged()); |
| 220 // Load value from current parent frame by given offset in bytes. | 221 // Load value from current parent frame by given offset in bytes. |
| 221 compiler::Node* LoadFromParentFrame( | 222 compiler::Node* LoadFromParentFrame( |
| 222 int offset, MachineType rep = MachineType::AnyTagged()); | 223 int offset, MachineType rep = MachineType::AnyTagged()); |
| 223 | 224 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 compiler::Node* LoadMapPrototypeInfo(compiler::Node* map, | 280 compiler::Node* LoadMapPrototypeInfo(compiler::Node* map, |
| 280 Label* if_has_no_proto_info); | 281 Label* if_has_no_proto_info); |
| 281 // Load the instance size of a Map. | 282 // Load the instance size of a Map. |
| 282 compiler::Node* LoadMapInstanceSize(compiler::Node* map); | 283 compiler::Node* LoadMapInstanceSize(compiler::Node* map); |
| 283 // Load the inobject properties count of a Map (valid only for JSObjects). | 284 // Load the inobject properties count of a Map (valid only for JSObjects). |
| 284 compiler::Node* LoadMapInobjectProperties(compiler::Node* map); | 285 compiler::Node* LoadMapInobjectProperties(compiler::Node* map); |
| 285 // Load the constructor function index of a Map (only for primitive maps). | 286 // Load the constructor function index of a Map (only for primitive maps). |
| 286 compiler::Node* LoadMapConstructorFunctionIndex(compiler::Node* map); | 287 compiler::Node* LoadMapConstructorFunctionIndex(compiler::Node* map); |
| 287 // Load the constructor of a Map (equivalent to Map::GetConstructor()). | 288 // Load the constructor of a Map (equivalent to Map::GetConstructor()). |
| 288 compiler::Node* LoadMapConstructor(compiler::Node* map); | 289 compiler::Node* LoadMapConstructor(compiler::Node* map); |
| 289 // Check whether the map is for an object with special properties, such as a | |
| 290 // JSProxy or an object with interceptors. | |
| 291 compiler::Node* IsSpecialReceiverMap(compiler::Node* map); | |
| 292 compiler::Node* IsSpecialReceiverInstanceType(compiler::Node* instance_type); | |
| 293 // Check if the map is set for slow properties. | 290 // Check if the map is set for slow properties. |
| 294 compiler::Node* IsDictionaryMap(compiler::Node* map); | 291 compiler::Node* IsDictionaryMap(compiler::Node* map); |
| 295 | 292 |
| 296 // Load the hash field of a name as an uint32 value. | 293 // Load the hash field of a name as an uint32 value. |
| 297 compiler::Node* LoadNameHashField(compiler::Node* name); | 294 compiler::Node* LoadNameHashField(compiler::Node* name); |
| 298 // Load the hash value of a name as an uint32 value. | 295 // Load the hash value of a name as an uint32 value. |
| 299 // If {if_hash_not_computed} label is specified then it also checks if | 296 // If {if_hash_not_computed} label is specified then it also checks if |
| 300 // hash is actually computed. | 297 // hash is actually computed. |
| 301 compiler::Node* LoadNameHash(compiler::Node* name, | 298 compiler::Node* LoadNameHash(compiler::Node* name, |
| 302 Label* if_hash_not_computed = nullptr); | 299 Label* if_hash_not_computed = nullptr); |
| 303 | 300 |
| 304 // Load length field of a String object. | 301 // Load length field of a String object. |
| 305 compiler::Node* LoadStringLength(compiler::Node* object); | 302 compiler::Node* LoadStringLength(compiler::Node* object); |
| 306 // Load value field of a JSValue object. | 303 // Load value field of a JSValue object. |
| 307 compiler::Node* LoadJSValueValue(compiler::Node* object); | 304 compiler::Node* LoadJSValueValue(compiler::Node* object); |
| 308 // Load value field of a WeakCell object. | 305 // Load value field of a WeakCell object. |
| 306 compiler::Node* LoadWeakCellValueUnchecked(compiler::Node* weak_cell); | |
| 309 compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell, | 307 compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell, |
| 310 Label* if_cleared = nullptr); | 308 Label* if_cleared = nullptr); |
| 311 | 309 |
| 312 // Load an array element from a FixedArray. | 310 // Load an array element from a FixedArray. |
| 313 compiler::Node* LoadFixedArrayElement( | 311 compiler::Node* LoadFixedArrayElement( |
| 314 compiler::Node* object, compiler::Node* index, int additional_offset = 0, | 312 compiler::Node* object, compiler::Node* index, int additional_offset = 0, |
| 315 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 313 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
| 316 // Load an array element from a FixedArray, untag it and return it as Word32. | 314 // Load an array element from a FixedArray, untag it and return it as Word32. |
| 317 compiler::Node* LoadAndUntagToWord32FixedArrayElement( | 315 compiler::Node* LoadAndUntagToWord32FixedArrayElement( |
| 318 compiler::Node* object, compiler::Node* index, int additional_offset = 0, | 316 compiler::Node* object, compiler::Node* index, int additional_offset = 0, |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 char const* method_name); | 600 char const* method_name); |
| 603 | 601 |
| 604 // Throws a TypeError for {method_name} if {value} is not of the given | 602 // Throws a TypeError for {method_name} if {value} is not of the given |
| 605 // instance type. Returns {value}'s map. | 603 // instance type. Returns {value}'s map. |
| 606 compiler::Node* ThrowIfNotInstanceType(compiler::Node* context, | 604 compiler::Node* ThrowIfNotInstanceType(compiler::Node* context, |
| 607 compiler::Node* value, | 605 compiler::Node* value, |
| 608 InstanceType instance_type, | 606 InstanceType instance_type, |
| 609 char const* method_name); | 607 char const* method_name); |
| 610 | 608 |
| 611 // Type checks. | 609 // Type checks. |
| 610 // Check whether the map is for an object with special properties, such as a | |
| 611 // JSProxy or an object with interceptors. | |
| 612 compiler::Node* IsSpecialReceiverMap(compiler::Node* map); | |
| 613 compiler::Node* IsSpecialReceiverInstanceType(compiler::Node* instance_type); | |
| 612 compiler::Node* IsStringInstanceType(compiler::Node* instance_type); | 614 compiler::Node* IsStringInstanceType(compiler::Node* instance_type); |
| 615 compiler::Node* IsString(compiler::Node* object); | |
| 616 compiler::Node* IsJSObject(compiler::Node* object); | |
| 613 compiler::Node* IsJSReceiverInstanceType(compiler::Node* instance_type); | 617 compiler::Node* IsJSReceiverInstanceType(compiler::Node* instance_type); |
| 614 | 618 compiler::Node* IsJSReceiver(compiler::Node* object); |
| 619 compiler::Node* IsMap(compiler::Node* object); | |
| 615 compiler::Node* IsCallableMap(compiler::Node* map); | 620 compiler::Node* IsCallableMap(compiler::Node* map); |
| 621 compiler::Node* IsName(compiler::Node* object); | |
| 622 compiler::Node* IsJSValue(compiler::Node* object); | |
| 623 compiler::Node* IsJSArray(compiler::Node* object); | |
| 624 compiler::Node* IsNativeContext(compiler::Node* object); | |
| 625 compiler::Node* IsWeakCell(compiler::Node* object); | |
| 626 compiler::Node* IsFixedDoubleArray(compiler::Node* object); | |
| 627 compiler::Node* IsHashTable(compiler::Node* object); | |
| 628 compiler::Node* IsDictionary(compiler::Node* object); | |
| 629 compiler::Node* IsUnseededNumberDictionary(compiler::Node* object); | |
| 616 | 630 |
| 617 // String helpers. | 631 // String helpers. |
| 618 // Load a character from a String (might flatten a ConsString). | 632 // Load a character from a String (might flatten a ConsString). |
| 619 compiler::Node* StringCharCodeAt(compiler::Node* string, | 633 compiler::Node* StringCharCodeAt(compiler::Node* string, |
| 620 compiler::Node* smi_index); | 634 compiler::Node* smi_index); |
| 621 // Return the single character string with only {code}. | 635 // Return the single character string with only {code}. |
| 622 compiler::Node* StringFromCharCode(compiler::Node* code); | 636 compiler::Node* StringFromCharCode(compiler::Node* code); |
| 623 // Return a new string object which holds a substring containing the range | 637 // Return a new string object which holds a substring containing the range |
| 624 // [from,to[ of string. |from| and |to| are expected to be tagged. | 638 // [from,to[ of string. |from| and |to| are expected to be tagged. |
| 625 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, | 639 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 | 1163 |
| 1150 compiler::Node* SmiShiftBitsConstant(); | 1164 compiler::Node* SmiShiftBitsConstant(); |
| 1151 | 1165 |
| 1152 // Emits keyed sloppy arguments load if the |value| is nullptr or store | 1166 // Emits keyed sloppy arguments load if the |value| is nullptr or store |
| 1153 // otherwise. Returns either the loaded value or |value|. | 1167 // otherwise. Returns either the loaded value or |value|. |
| 1154 compiler::Node* EmitKeyedSloppyArguments(compiler::Node* receiver, | 1168 compiler::Node* EmitKeyedSloppyArguments(compiler::Node* receiver, |
| 1155 compiler::Node* key, | 1169 compiler::Node* key, |
| 1156 compiler::Node* value, | 1170 compiler::Node* value, |
| 1157 Label* bailout); | 1171 Label* bailout); |
| 1158 | 1172 |
| 1173 compiler::Node* AllocateSlicedString(Heap::RootListIndex map_root_index, | |
| 1174 compiler::Node* length, | |
| 1175 compiler::Node* parent, | |
| 1176 compiler::Node* offset); | |
| 1177 | |
| 1178 compiler::Node* AllocateConsString(Heap::RootListIndex map_root_index, | |
| 1179 compiler::Node* length, | |
| 1180 compiler::Node* first, | |
| 1181 compiler::Node* second, | |
| 1182 AllocationFlags flags); | |
| 1183 | |
| 1159 static const int kElementLoopUnrollThreshold = 8; | 1184 static const int kElementLoopUnrollThreshold = 8; |
| 1160 }; | 1185 }; |
| 1161 | 1186 |
| 1162 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) | 1187 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) |
| 1188 #define CSA_SLOW_ASSERT(x) SlowAssert((x), #x, __FILE__, __LINE__) | |
|
Igor Sheludko
2016/10/26 13:24:27
I think we don't need SlowAssert function as we ar
Camillo Bruni
2016/10/28 11:09:33
ok, can do it this way.
| |
| 1163 | 1189 |
| 1164 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1190 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
| 1165 | 1191 |
| 1166 } // namespace internal | 1192 } // namespace internal |
| 1167 } // namespace v8 | 1193 } // namespace v8 |
| 1168 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1194 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |