OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | 1103 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
1104 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; | 1104 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
1105 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; | 1105 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; |
1106 | 1106 |
1107 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); | 1107 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); |
1108 }; | 1108 }; |
1109 | 1109 |
1110 | 1110 |
1111 class StoreGlobalStub : public HandlerStub { | 1111 class StoreGlobalStub : public HandlerStub { |
1112 public: | 1112 public: |
1113 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) | 1113 StoreGlobalStub(Isolate* isolate, PropertyCellType type, |
| 1114 Maybe<PropertyCellConstantType> constant_type, |
| 1115 bool check_global) |
1114 : HandlerStub(isolate) { | 1116 : HandlerStub(isolate) { |
1115 set_sub_minor_key(IsConstantBits::encode(is_constant) | | 1117 PropertyCellConstantType encoded_constant_type = |
| 1118 constant_type.FromMaybe(PropertyCellConstantType::kSmi); |
| 1119 set_sub_minor_key(CellTypeBits::encode(type) | |
| 1120 ConstantTypeBits::encode(encoded_constant_type) | |
1116 CheckGlobalBits::encode(check_global)); | 1121 CheckGlobalBits::encode(check_global)); |
1117 } | 1122 } |
1118 | 1123 |
1119 static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) { | 1124 static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) { |
1120 return isolate->factory()->uninitialized_value(); | 1125 return isolate->factory()->uninitialized_value(); |
1121 } | 1126 } |
1122 | 1127 |
| 1128 static Handle<HeapObject> global_map_placeholder(Isolate* isolate) { |
| 1129 return isolate->factory()->termination_exception(); |
| 1130 } |
| 1131 |
1123 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, | 1132 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, |
1124 Handle<PropertyCell> cell) { | 1133 Handle<PropertyCell> cell) { |
| 1134 Code::FindAndReplacePattern pattern; |
1125 if (check_global()) { | 1135 if (check_global()) { |
1126 Code::FindAndReplacePattern pattern; | 1136 pattern.Add(handle(global_map_placeholder(isolate())->map()), |
1127 pattern.Add(isolate()->factory()->meta_map(), | |
1128 Map::WeakCellForMap(Handle<Map>(global->map()))); | 1137 Map::WeakCellForMap(Handle<Map>(global->map()))); |
1129 pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()), | |
1130 isolate()->factory()->NewWeakCell(cell)); | |
1131 return CodeStub::GetCodeCopy(pattern); | |
1132 } else { | |
1133 Code::FindAndReplacePattern pattern; | |
1134 pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()), | |
1135 isolate()->factory()->NewWeakCell(cell)); | |
1136 return CodeStub::GetCodeCopy(pattern); | |
1137 } | 1138 } |
| 1139 pattern.Add(handle(property_cell_placeholder(isolate())->map()), |
| 1140 isolate()->factory()->NewWeakCell(cell)); |
| 1141 return CodeStub::GetCodeCopy(pattern); |
1138 } | 1142 } |
1139 | 1143 |
1140 Code::Kind kind() const override { return Code::STORE_IC; } | 1144 Code::Kind kind() const override { return Code::STORE_IC; } |
1141 | 1145 |
1142 bool is_constant() const { return IsConstantBits::decode(sub_minor_key()); } | 1146 PropertyCellType cell_type() const { |
| 1147 return CellTypeBits::decode(sub_minor_key()); |
| 1148 } |
| 1149 |
| 1150 PropertyCellConstantType constant_type() const { |
| 1151 DCHECK(PropertyCellType::kConstantType == cell_type()); |
| 1152 return ConstantTypeBits::decode(sub_minor_key()); |
| 1153 } |
1143 | 1154 |
1144 bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } | 1155 bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } |
1145 | 1156 |
1146 void set_is_constant(bool value) { | |
1147 set_sub_minor_key(IsConstantBits::update(sub_minor_key(), value)); | |
1148 } | |
1149 | |
1150 Representation representation() { | 1157 Representation representation() { |
1151 return Representation::FromKind( | 1158 return Representation::FromKind( |
1152 RepresentationBits::decode(sub_minor_key())); | 1159 RepresentationBits::decode(sub_minor_key())); |
1153 } | 1160 } |
1154 | 1161 |
1155 void set_representation(Representation r) { | 1162 void set_representation(Representation r) { |
1156 set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); | 1163 set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); |
1157 } | 1164 } |
1158 | 1165 |
1159 private: | 1166 private: |
1160 class IsConstantBits: public BitField<bool, 0, 1> {}; | 1167 class CellTypeBits : public BitField<PropertyCellType, 0, 2> {}; |
1161 class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; | 1168 class ConstantTypeBits : public BitField<PropertyCellConstantType, 2, 2> {}; |
1162 class CheckGlobalBits: public BitField<bool, 9, 1> {}; | 1169 class RepresentationBits : public BitField<Representation::Kind, 4, 8> {}; |
| 1170 class CheckGlobalBits : public BitField<bool, 12, 1> {}; |
1163 | 1171 |
1164 DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub); | 1172 DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub); |
1165 }; | 1173 }; |
1166 | 1174 |
1167 | 1175 |
1168 class CallApiFunctionStub : public PlatformCodeStub { | 1176 class CallApiFunctionStub : public PlatformCodeStub { |
1169 public: | 1177 public: |
1170 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) | 1178 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) |
1171 : PlatformCodeStub(isolate) { | 1179 : PlatformCodeStub(isolate) { |
1172 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); | 1180 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2754 | 2762 |
2755 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR | 2763 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
2756 #undef DEFINE_PLATFORM_CODE_STUB | 2764 #undef DEFINE_PLATFORM_CODE_STUB |
2757 #undef DEFINE_HANDLER_CODE_STUB | 2765 #undef DEFINE_HANDLER_CODE_STUB |
2758 #undef DEFINE_HYDROGEN_CODE_STUB | 2766 #undef DEFINE_HYDROGEN_CODE_STUB |
2759 #undef DEFINE_CODE_STUB | 2767 #undef DEFINE_CODE_STUB |
2760 #undef DEFINE_CODE_STUB_BASE | 2768 #undef DEFINE_CODE_STUB_BASE |
2761 } } // namespace v8::internal | 2769 } } // namespace v8::internal |
2762 | 2770 |
2763 #endif // V8_CODE_STUBS_H_ | 2771 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |