| 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" | 
|    11 #include "src/globals.h" |    11 #include "src/globals.h" | 
|    12 #include "src/objects.h" |    12 #include "src/objects.h" | 
|    13  |    13  | 
|    14 namespace v8 { |    14 namespace v8 { | 
|    15 namespace internal { |    15 namespace internal { | 
|    16  |    16  | 
|    17 class CallInterfaceDescriptor; |    17 class CallInterfaceDescriptor; | 
|    18 class CodeStubArguments; |    18 class CodeStubArguments; | 
|    19 class StatsCounter; |    19 class StatsCounter; | 
|    20 class StubCache; |    20 class StubCache; | 
|    21  |    21  | 
|    22 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; |    22 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; | 
|    23  |    23  | 
|    24 #define HEAP_CONSTANT_LIST(V)                         \ |    24 #define HEAP_CONSTANT_LIST(V)                         \ | 
|    25   V(AccessorInfoMap, AccessorInfoMap)                 \ |    25   V(AccessorInfoMap, AccessorInfoMap)                 \ | 
|    26   V(AccessorPairMap, AccessorPairMap)                 \ |    26   V(AccessorPairMap, AccessorPairMap)                 \ | 
|    27   V(AllocationSiteMap, AllocationSiteMap)             \ |    27   V(AllocationSiteMap, AllocationSiteMap)             \ | 
|    28   V(BooleanMap, BooleanMap)                           \ |    28   V(BooleanMap, BooleanMap)                           \ | 
|    29   V(CodeMap, CodeMap)                                 \ |    29   V(CodeMap, CodeMap)                                 \ | 
 |    30   V(empty_string, EmptyString)                        \ | 
 |    31   V(length_string, LengthString)                      \ | 
 |    32   V(prototype_string, PrototypeString)                \ | 
|    30   V(EmptyFixedArray, EmptyFixedArray)                 \ |    33   V(EmptyFixedArray, EmptyFixedArray)                 \ | 
|    31   V(empty_string, EmptyString)                        \ |  | 
|    32   V(EmptyWeakCell, EmptyWeakCell)                     \ |    34   V(EmptyWeakCell, EmptyWeakCell)                     \ | 
|    33   V(FalseValue, False)                                \ |    35   V(FalseValue, False)                                \ | 
|    34   V(FeedbackVectorMap, FeedbackVectorMap)             \ |    36   V(FeedbackVectorMap, FeedbackVectorMap)             \ | 
|    35   V(FixedArrayMap, FixedArrayMap)                     \ |    37   V(FixedArrayMap, FixedArrayMap)                     \ | 
|    36   V(FixedCOWArrayMap, FixedCOWArrayMap)               \ |    38   V(FixedCOWArrayMap, FixedCOWArrayMap)               \ | 
|    37   V(FixedDoubleArrayMap, FixedDoubleArrayMap)         \ |    39   V(FixedDoubleArrayMap, FixedDoubleArrayMap)         \ | 
|    38   V(FunctionTemplateInfoMap, FunctionTemplateInfoMap) \ |    40   V(FunctionTemplateInfoMap, FunctionTemplateInfoMap) \ | 
|    39   V(GlobalPropertyCellMap, PropertyCellMap)           \ |  | 
|    40   V(has_instance_symbol, HasInstanceSymbol)           \ |    41   V(has_instance_symbol, HasInstanceSymbol)           \ | 
|    41   V(HeapNumberMap, HeapNumberMap)                     \ |    42   V(HeapNumberMap, HeapNumberMap)                     \ | 
|    42   V(length_string, LengthString)                      \ |    43   V(NoClosuresCellMap, NoClosuresCellMap)             \ | 
 |    44   V(OneClosureCellMap, OneClosureCellMap)             \ | 
|    43   V(ManyClosuresCellMap, ManyClosuresCellMap)         \ |    45   V(ManyClosuresCellMap, ManyClosuresCellMap)         \ | 
|    44   V(MetaMap, MetaMap)                                 \ |  | 
|    45   V(MinusZeroValue, MinusZero)                        \ |    46   V(MinusZeroValue, MinusZero)                        \ | 
|    46   V(MutableHeapNumberMap, MutableHeapNumberMap)       \ |  | 
|    47   V(NanValue, Nan)                                    \ |    47   V(NanValue, Nan)                                    \ | 
|    48   V(NoClosuresCellMap, NoClosuresCellMap)             \ |  | 
|    49   V(NullValue, Null)                                  \ |    48   V(NullValue, Null)                                  \ | 
|    50   V(OneClosureCellMap, OneClosureCellMap)             \ |    49   V(GlobalPropertyCellMap, PropertyCellMap)           \ | 
|    51   V(prototype_string, PrototypeString)                \ |  | 
|    52   V(SpeciesProtector, SpeciesProtector)               \ |  | 
|    53   V(SymbolMap, SymbolMap)                             \ |    50   V(SymbolMap, SymbolMap)                             \ | 
|    54   V(TheHoleValue, TheHole)                            \ |    51   V(TheHoleValue, TheHole)                            \ | 
|    55   V(TrueValue, True)                                  \ |    52   V(TrueValue, True)                                  \ | 
|    56   V(Tuple2Map, Tuple2Map)                             \ |    53   V(Tuple2Map, Tuple2Map)                             \ | 
|    57   V(Tuple3Map, Tuple3Map)                             \ |    54   V(Tuple3Map, Tuple3Map)                             \ | 
|    58   V(UndefinedValue, Undefined)                        \ |    55   V(UndefinedValue, Undefined)                        \ | 
|    59   V(WeakCellMap, WeakCellMap) |    56   V(WeakCellMap, WeakCellMap)                         \ | 
 |    57   V(SpeciesProtector, SpeciesProtector) | 
|    60  |    58  | 
|    61 // Provides JavaScript-specific "macro-assembler" functionality on top of the |    59 // Provides JavaScript-specific "macro-assembler" functionality on top of the | 
|    62 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |    60 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, | 
|    63 // it's possible to add JavaScript-specific useful CodeAssembler "macros" |    61 // it's possible to add JavaScript-specific useful CodeAssembler "macros" | 
|    64 // without modifying files in the compiler directory (and requiring a review |    62 // without modifying files in the compiler directory (and requiring a review | 
|    65 // from a compiler directory OWNER). |    63 // from a compiler directory OWNER). | 
|    66 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { |    64 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { | 
|    67  public: |    65  public: | 
|    68   typedef compiler::Node Node; |    66   typedef compiler::Node Node; | 
|    69  |    67  | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   111   Node* ParameterToTagged(Node* value, ParameterMode mode) { |   109   Node* ParameterToTagged(Node* value, ParameterMode mode) { | 
|   112     if (mode != SMI_PARAMETERS) value = SmiTag(value); |   110     if (mode != SMI_PARAMETERS) value = SmiTag(value); | 
|   113     return value; |   111     return value; | 
|   114   } |   112   } | 
|   115  |   113  | 
|   116   Node* TaggedToParameter(Node* value, ParameterMode mode) { |   114   Node* TaggedToParameter(Node* value, ParameterMode mode) { | 
|   117     if (mode != SMI_PARAMETERS) value = SmiUntag(value); |   115     if (mode != SMI_PARAMETERS) value = SmiUntag(value); | 
|   118     return value; |   116     return value; | 
|   119   } |   117   } | 
|   120  |   118  | 
|   121   Node* MatchesParameterMode(Node* value, ParameterMode mode); |  | 
|   122  |  | 
|   123 #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \ |   119 #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \ | 
|   124   Node* OpName(Node* a, Node* b, ParameterMode mode) {   \ |   120   Node* OpName(Node* a, Node* b, ParameterMode mode) {   \ | 
|   125     if (mode == SMI_PARAMETERS) {                        \ |   121     if (mode == SMI_PARAMETERS) {                        \ | 
|   126       return SmiOpName(a, b);                            \ |   122       return SmiOpName(a, b);                            \ | 
|   127     } else {                                             \ |   123     } else {                                             \ | 
|   128       DCHECK_EQ(INTPTR_PARAMETERS, mode);                \ |   124       DCHECK_EQ(INTPTR_PARAMETERS, mode);                \ | 
|   129       return IntPtrOpName(a, b);                         \ |   125       return IntPtrOpName(a, b);                         \ | 
|   130     }                                                    \ |   126     }                                                    \ | 
|   131   } |   127   } | 
|   132   PARAMETER_BINOP(IntPtrOrSmiMin, IntPtrMin, SmiMin) |   128   PARAMETER_BINOP(IntPtrOrSmiMin, IntPtrMin, SmiMin) | 
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   767   Node* IsJSReceiver(Node* object); |   763   Node* IsJSReceiver(Node* object); | 
|   768   Node* IsJSReceiverMap(Node* map); |   764   Node* IsJSReceiverMap(Node* map); | 
|   769   Node* IsMap(Node* object); |   765   Node* IsMap(Node* object); | 
|   770   Node* IsCallableMap(Node* map); |   766   Node* IsCallableMap(Node* map); | 
|   771   Node* IsDeprecatedMap(Node* map); |   767   Node* IsDeprecatedMap(Node* map); | 
|   772   Node* IsCallable(Node* object); |   768   Node* IsCallable(Node* object); | 
|   773   Node* IsBoolean(Node* object); |   769   Node* IsBoolean(Node* object); | 
|   774   Node* IsPropertyCell(Node* object); |   770   Node* IsPropertyCell(Node* object); | 
|   775   Node* IsAccessorInfo(Node* object); |   771   Node* IsAccessorInfo(Node* object); | 
|   776   Node* IsAccessorPair(Node* object); |   772   Node* IsAccessorPair(Node* object); | 
|   777   Node* IsAnyHeapNumber(Node* object); |  | 
|   778   Node* IsMutableHeapNumber(Node* object); |  | 
|   779   Node* IsHeapNumber(Node* object); |   773   Node* IsHeapNumber(Node* object); | 
|   780   Node* IsName(Node* object); |   774   Node* IsName(Node* object); | 
|   781   Node* IsSymbol(Node* object); |   775   Node* IsSymbol(Node* object); | 
|   782   Node* IsPrivateSymbol(Node* object); |   776   Node* IsPrivateSymbol(Node* object); | 
|   783   Node* IsJSValueInstanceType(Node* instance_type); |   777   Node* IsJSValueInstanceType(Node* instance_type); | 
|   784   Node* IsJSValue(Node* object); |   778   Node* IsJSValue(Node* object); | 
|   785   Node* IsJSValueMap(Node* map); |   779   Node* IsJSValueMap(Node* map); | 
|   786   Node* IsJSArrayInstanceType(Node* instance_type); |   780   Node* IsJSArrayInstanceType(Node* instance_type); | 
|   787   Node* IsJSArray(Node* object); |   781   Node* IsJSArray(Node* object); | 
|   788   Node* IsJSArrayMap(Node* object); |   782   Node* IsJSArrayMap(Node* object); | 
|   789   Node* IsFixedArray(Node* object); |  | 
|   790   Node* IsFixedArrayWithKindOrEmpty(Node* object, ElementsKind kind); |  | 
|   791   Node* IsFixedArrayWithKind(Node* object, ElementsKind kind); |  | 
|   792   Node* IsNativeContext(Node* object); |   783   Node* IsNativeContext(Node* object); | 
|   793   Node* IsWeakCell(Node* object); |   784   Node* IsWeakCell(Node* object); | 
|   794   Node* IsFixedDoubleArray(Node* object); |   785   Node* IsFixedDoubleArray(Node* object); | 
|   795   Node* IsHashTable(Node* object); |   786   Node* IsHashTable(Node* object); | 
|   796   Node* IsDictionary(Node* object); |   787   Node* IsDictionary(Node* object); | 
|   797   Node* IsUnseededNumberDictionary(Node* object); |   788   Node* IsUnseededNumberDictionary(Node* object); | 
|   798   Node* IsConstructorMap(Node* map); |   789   Node* IsConstructorMap(Node* map); | 
|   799   Node* IsJSFunctionInstanceType(Node* instance_type); |   790   Node* IsJSFunctionInstanceType(Node* instance_type); | 
|   800   Node* IsJSFunction(Node* object); |   791   Node* IsJSFunction(Node* object); | 
|   801   Node* IsJSFunctionMap(Node* object); |   792   Node* IsJSFunctionMap(Node* object); | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|   832   // [from,to[ of string.  |from| and |to| are expected to be tagged. |   823   // [from,to[ of string.  |from| and |to| are expected to be tagged. | 
|   833   // If flags has the value FROM_TO_ARE_BOUNDED then from and to are in |   824   // If flags has the value FROM_TO_ARE_BOUNDED then from and to are in | 
|   834   // the range [0, string-length) |   825   // the range [0, string-length) | 
|   835   Node* SubString(Node* context, Node* string, Node* from, Node* to, |   826   Node* SubString(Node* context, Node* string, Node* from, Node* to, | 
|   836                   SubStringFlags flags = SubStringFlags::NONE); |   827                   SubStringFlags flags = SubStringFlags::NONE); | 
|   837  |   828  | 
|   838   // Return a new string object produced by concatenating |first| with |second|. |   829   // Return a new string object produced by concatenating |first| with |second|. | 
|   839   Node* StringAdd(Node* context, Node* first, Node* second, |   830   Node* StringAdd(Node* context, Node* first, Node* second, | 
|   840                   AllocationFlags flags = kNone); |   831                   AllocationFlags flags = kNone); | 
|   841  |   832  | 
 |   833   // Unpack the external string, returning a pointer that (offset-wise) looks | 
 |   834   // like a sequential string. | 
 |   835   // Note that this pointer is not tagged and does not point to a real | 
 |   836   // sequential string instance, and may only be used to access the string | 
 |   837   // data. The pointer is GC-safe as long as a reference to the container | 
 |   838   // ExternalString is live. | 
 |   839   // |string| must be an external string. Bailout for short external strings. | 
 |   840   Node* TryDerefExternalString(Node* const string, Node* const instance_type, | 
 |   841                                Label* if_bailout); | 
 |   842  | 
|   842   // Check if |var_string| has an indirect (thin or flat cons) string type, |   843   // Check if |var_string| has an indirect (thin or flat cons) string type, | 
|   843   // and unpack it if so. |   844   // and unpack it if so. | 
|   844   void MaybeDerefIndirectString(Variable* var_string, Node* instance_type, |   845   void MaybeDerefIndirectString(Variable* var_string, Node* instance_type, | 
|   845                                 Variable* var_did_something); |   846                                 Variable* var_did_something); | 
|   846   // Check if |var_left| or |var_right| has an indirect (thin or flat cons) |   847   // Check if |var_left| or |var_right| has an indirect (thin or flat cons) | 
|   847   // string type, and unpack it/them if so. Fall through if nothing was done. |   848   // string type, and unpack it/them if so. Fall through if nothing was done. | 
|   848   void MaybeDerefIndirectStrings(Variable* var_left, Node* left_instance_type, |   849   void MaybeDerefIndirectStrings(Variable* var_left, Node* left_instance_type, | 
|   849                                  Variable* var_right, Node* right_instance_type, |   850                                  Variable* var_right, Node* right_instance_type, | 
|   850                                  Label* did_something); |   851                                  Label* did_something); | 
|   851  |   852  | 
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1654   } |  1655   } | 
|  1655 #else |  1656 #else | 
|  1656 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |  1657 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 
|  1657 #endif |  1658 #endif | 
|  1658  |  1659  | 
|  1659 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |  1660 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 
|  1660  |  1661  | 
|  1661 }  // namespace internal |  1662 }  // namespace internal | 
|  1662 }  // namespace v8 |  1663 }  // namespace v8 | 
|  1663 #endif  // V8_CODE_STUB_ASSEMBLER_H_ |  1664 #endif  // V8_CODE_STUB_ASSEMBLER_H_ | 
| OLD | NEW |