Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1 | // Copyright 2014 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 | #include "src/compiler/js-operator.h" |
| 6 | |
| 7 | #include <limits> |
| 8 | |
| 9 | #include "src/base/lazy-instance.h" |
| 10 | #include "src/compiler/opcodes.h" |
| 11 | #include "src/compiler/operator.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 12 | #include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker! |
| 13 | #include "src/type-feedback-vector-inl.h" |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 14 | |
| 15 | namespace v8 { |
| 16 | namespace internal { |
| 17 | namespace compiler { |
| 18 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 19 | VectorSlotPair::VectorSlotPair() {} |
| 20 | |
| 21 | |
| 22 | int VectorSlotPair::index() const { |
| 23 | return vector_.is_null() ? -1 : vector_->GetIndex(slot_); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 27 | bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs) { |
| 28 | return lhs.slot() == rhs.slot() && |
| 29 | lhs.vector().location() == rhs.vector().location(); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | bool operator!=(VectorSlotPair const& lhs, VectorSlotPair const& rhs) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 34 | return !(lhs == rhs); |
| 35 | } |
| 36 | |
| 37 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 38 | size_t hash_value(VectorSlotPair const& p) { |
| 39 | return base::hash_combine(p.slot(), p.vector().location()); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | ConvertReceiverMode ConvertReceiverModeOf(Operator const* op) { |
| 44 | DCHECK_EQ(IrOpcode::kJSConvertReceiver, op->opcode()); |
| 45 | return OpParameter<ConvertReceiverMode>(op); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | ToBooleanHints ToBooleanHintsOf(Operator const* op) { |
| 50 | DCHECK_EQ(IrOpcode::kJSToBoolean, op->opcode()); |
| 51 | return OpParameter<ToBooleanHints>(op); |
| 52 | } |
| 53 | |
| 54 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 55 | bool operator==(CallConstructParameters const& lhs, |
| 56 | CallConstructParameters const& rhs) { |
| 57 | return lhs.arity() == rhs.arity() && lhs.feedback() == rhs.feedback(); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | bool operator!=(CallConstructParameters const& lhs, |
| 62 | CallConstructParameters const& rhs) { |
| 63 | return !(lhs == rhs); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | size_t hash_value(CallConstructParameters const& p) { |
| 68 | return base::hash_combine(p.arity(), p.feedback()); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | std::ostream& operator<<(std::ostream& os, CallConstructParameters const& p) { |
| 73 | return os << p.arity(); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | CallConstructParameters const& CallConstructParametersOf(Operator const* op) { |
| 78 | DCHECK_EQ(IrOpcode::kJSCallConstruct, op->opcode()); |
| 79 | return OpParameter<CallConstructParameters>(op); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | |
| 83 | std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 84 | os << p.arity() << ", " << p.convert_mode() << ", " << p.tail_call_mode(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 85 | return os; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | |
| 89 | const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { |
| 90 | DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); |
| 91 | return OpParameter<CallFunctionParameters>(op); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | bool operator==(CallRuntimeParameters const& lhs, |
| 96 | CallRuntimeParameters const& rhs) { |
| 97 | return lhs.id() == rhs.id() && lhs.arity() == rhs.arity(); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | bool operator!=(CallRuntimeParameters const& lhs, |
| 102 | CallRuntimeParameters const& rhs) { |
| 103 | return !(lhs == rhs); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | size_t hash_value(CallRuntimeParameters const& p) { |
| 108 | return base::hash_combine(p.id(), p.arity()); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | std::ostream& operator<<(std::ostream& os, CallRuntimeParameters const& p) { |
| 113 | return os << p.id() << ", " << p.arity(); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) { |
| 118 | DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode()); |
| 119 | return OpParameter<CallRuntimeParameters>(op); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | ContextAccess::ContextAccess(size_t depth, size_t index, bool immutable) |
| 124 | : immutable_(immutable), |
| 125 | depth_(static_cast<uint16_t>(depth)), |
| 126 | index_(static_cast<uint32_t>(index)) { |
| 127 | DCHECK(depth <= std::numeric_limits<uint16_t>::max()); |
| 128 | DCHECK(index <= std::numeric_limits<uint32_t>::max()); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | bool operator==(ContextAccess const& lhs, ContextAccess const& rhs) { |
| 133 | return lhs.depth() == rhs.depth() && lhs.index() == rhs.index() && |
| 134 | lhs.immutable() == rhs.immutable(); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | bool operator!=(ContextAccess const& lhs, ContextAccess const& rhs) { |
| 139 | return !(lhs == rhs); |
| 140 | } |
| 141 | |
| 142 | |
| 143 | size_t hash_value(ContextAccess const& access) { |
| 144 | return base::hash_combine(access.depth(), access.index(), access.immutable()); |
| 145 | } |
| 146 | |
| 147 | |
| 148 | std::ostream& operator<<(std::ostream& os, ContextAccess const& access) { |
| 149 | return os << access.depth() << ", " << access.index() << ", " |
| 150 | << access.immutable(); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | ContextAccess const& ContextAccessOf(Operator const* op) { |
| 155 | DCHECK(op->opcode() == IrOpcode::kJSLoadContext || |
| 156 | op->opcode() == IrOpcode::kJSStoreContext); |
| 157 | return OpParameter<ContextAccess>(op); |
| 158 | } |
| 159 | |
| 160 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 161 | bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { |
| 162 | return lhs.name().location() == rhs.name().location() && |
| 163 | lhs.language_mode() == rhs.language_mode() && |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 164 | lhs.feedback() == rhs.feedback(); |
| 165 | } |
| 166 | |
| 167 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 168 | bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 169 | return !(lhs == rhs); |
| 170 | } |
| 171 | |
| 172 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 173 | size_t hash_value(NamedAccess const& p) { |
| 174 | return base::hash_combine(p.name().location(), p.language_mode(), |
| 175 | p.feedback()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 179 | std::ostream& operator<<(std::ostream& os, NamedAccess const& p) { |
| 180 | return os << Brief(*p.name()) << ", " << p.language_mode(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 184 | NamedAccess const& NamedAccessOf(const Operator* op) { |
| 185 | DCHECK(op->opcode() == IrOpcode::kJSLoadNamed || |
| 186 | op->opcode() == IrOpcode::kJSStoreNamed); |
| 187 | return OpParameter<NamedAccess>(op); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) { |
| 192 | return os << p.language_mode(); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) { |
| 197 | return lhs.language_mode() == rhs.language_mode() && |
| 198 | lhs.feedback() == rhs.feedback(); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) { |
| 203 | return !(lhs == rhs); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | PropertyAccess const& PropertyAccessOf(const Operator* op) { |
| 208 | DCHECK(op->opcode() == IrOpcode::kJSLoadProperty || |
| 209 | op->opcode() == IrOpcode::kJSStoreProperty); |
| 210 | return OpParameter<PropertyAccess>(op); |
| 211 | } |
| 212 | |
| 213 | |
| 214 | size_t hash_value(PropertyAccess const& p) { |
| 215 | return base::hash_combine(p.language_mode(), p.feedback()); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | bool operator==(LoadGlobalParameters const& lhs, |
| 220 | LoadGlobalParameters const& rhs) { |
| 221 | return lhs.name().location() == rhs.name().location() && |
| 222 | lhs.feedback() == rhs.feedback() && |
| 223 | lhs.typeof_mode() == rhs.typeof_mode(); |
| 224 | } |
| 225 | |
| 226 | |
| 227 | bool operator!=(LoadGlobalParameters const& lhs, |
| 228 | LoadGlobalParameters const& rhs) { |
| 229 | return !(lhs == rhs); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | size_t hash_value(LoadGlobalParameters const& p) { |
| 234 | return base::hash_combine(p.name().location(), p.typeof_mode()); |
| 235 | } |
| 236 | |
| 237 | |
| 238 | std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) { |
| 239 | return os << Brief(*p.name()) << ", " << p.typeof_mode(); |
| 240 | } |
| 241 | |
| 242 | |
| 243 | const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) { |
| 244 | DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode()); |
| 245 | return OpParameter<LoadGlobalParameters>(op); |
| 246 | } |
| 247 | |
| 248 | |
| 249 | bool operator==(StoreGlobalParameters const& lhs, |
| 250 | StoreGlobalParameters const& rhs) { |
| 251 | return lhs.language_mode() == rhs.language_mode() && |
| 252 | lhs.name().location() == rhs.name().location() && |
| 253 | lhs.feedback() == rhs.feedback(); |
| 254 | } |
| 255 | |
| 256 | |
| 257 | bool operator!=(StoreGlobalParameters const& lhs, |
| 258 | StoreGlobalParameters const& rhs) { |
| 259 | return !(lhs == rhs); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | size_t hash_value(StoreGlobalParameters const& p) { |
| 264 | return base::hash_combine(p.language_mode(), p.name().location(), |
| 265 | p.feedback()); |
| 266 | } |
| 267 | |
| 268 | |
| 269 | std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) { |
| 270 | return os << p.language_mode() << ", " << Brief(*p.name()); |
| 271 | } |
| 272 | |
| 273 | |
| 274 | const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) { |
| 275 | DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode()); |
| 276 | return OpParameter<StoreGlobalParameters>(op); |
| 277 | } |
| 278 | |
| 279 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 280 | CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 281 | DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode()); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 282 | return OpParameter<CreateArgumentsType>(op); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | |
| 286 | bool operator==(CreateArrayParameters const& lhs, |
| 287 | CreateArrayParameters const& rhs) { |
| 288 | return lhs.arity() == rhs.arity() && |
| 289 | lhs.site().location() == rhs.site().location(); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | bool operator!=(CreateArrayParameters const& lhs, |
| 294 | CreateArrayParameters const& rhs) { |
| 295 | return !(lhs == rhs); |
| 296 | } |
| 297 | |
| 298 | |
| 299 | size_t hash_value(CreateArrayParameters const& p) { |
| 300 | return base::hash_combine(p.arity(), p.site().location()); |
| 301 | } |
| 302 | |
| 303 | |
| 304 | std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) { |
| 305 | os << p.arity(); |
| 306 | if (!p.site().is_null()) os << ", " << Brief(*p.site()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 307 | return os; |
| 308 | } |
| 309 | |
| 310 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 311 | const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) { |
| 312 | DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode()); |
| 313 | return OpParameter<CreateArrayParameters>(op); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 317 | bool operator==(CreateClosureParameters const& lhs, |
| 318 | CreateClosureParameters const& rhs) { |
| 319 | return lhs.pretenure() == rhs.pretenure() && |
| 320 | lhs.shared_info().location() == rhs.shared_info().location(); |
| 321 | } |
| 322 | |
| 323 | |
| 324 | bool operator!=(CreateClosureParameters const& lhs, |
| 325 | CreateClosureParameters const& rhs) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 326 | return !(lhs == rhs); |
| 327 | } |
| 328 | |
| 329 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 330 | size_t hash_value(CreateClosureParameters const& p) { |
| 331 | return base::hash_combine(p.pretenure(), p.shared_info().location()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 335 | std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) { |
| 336 | return os << p.pretenure() << ", " << Brief(*p.shared_info()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 340 | const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { |
| 341 | DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode()); |
| 342 | return OpParameter<CreateClosureParameters>(op); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 346 | bool operator==(CreateLiteralParameters const& lhs, |
| 347 | CreateLiteralParameters const& rhs) { |
| 348 | return lhs.constant().location() == rhs.constant().location() && |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 349 | lhs.length() == rhs.length() && lhs.flags() == rhs.flags() && |
| 350 | lhs.index() == rhs.index(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 354 | bool operator!=(CreateLiteralParameters const& lhs, |
| 355 | CreateLiteralParameters const& rhs) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 356 | return !(lhs == rhs); |
| 357 | } |
| 358 | |
| 359 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 360 | size_t hash_value(CreateLiteralParameters const& p) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 361 | return base::hash_combine(p.constant().location(), p.length(), p.flags(), |
| 362 | p.index()); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 366 | std::ostream& operator<<(std::ostream& os, CreateLiteralParameters const& p) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 367 | return os << Brief(*p.constant()) << ", " << p.length() << ", " << p.flags() |
| 368 | << ", " << p.index(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 372 | const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) { |
| 373 | DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray || |
| 374 | op->opcode() == IrOpcode::kJSCreateLiteralObject || |
| 375 | op->opcode() == IrOpcode::kJSCreateLiteralRegExp); |
| 376 | return OpParameter<CreateLiteralParameters>(op); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 377 | } |
| 378 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 379 | #define CACHED_OP_LIST(V) \ |
| 380 | V(Equal, Operator::kNoProperties, 2, 1) \ |
| 381 | V(NotEqual, Operator::kNoProperties, 2, 1) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 382 | V(StrictEqual, Operator::kPure, 2, 1) \ |
| 383 | V(StrictNotEqual, Operator::kPure, 2, 1) \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 384 | V(LessThan, Operator::kNoProperties, 2, 1) \ |
| 385 | V(GreaterThan, Operator::kNoProperties, 2, 1) \ |
| 386 | V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ |
| 387 | V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 388 | V(ToInteger, Operator::kNoProperties, 1, 1) \ |
| 389 | V(ToLength, Operator::kNoProperties, 1, 1) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 390 | V(ToName, Operator::kNoProperties, 1, 1) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 391 | V(ToNumber, Operator::kNoProperties, 1, 1) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 392 | V(ToObject, Operator::kFoldable, 1, 1) \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 393 | V(ToString, Operator::kNoProperties, 1, 1) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 394 | V(Create, Operator::kEliminatable, 2, 1) \ |
| 395 | V(CreateIterResultObject, Operator::kEliminatable, 2, 1) \ |
| 396 | V(HasProperty, Operator::kNoProperties, 2, 1) \ |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 397 | V(TypeOf, Operator::kPure, 1, 1) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 398 | V(InstanceOf, Operator::kNoProperties, 2, 1) \ |
| 399 | V(ForInDone, Operator::kPure, 2, 1) \ |
| 400 | V(ForInNext, Operator::kNoProperties, 4, 1) \ |
| 401 | V(ForInPrepare, Operator::kNoProperties, 1, 3) \ |
| 402 | V(ForInStep, Operator::kPure, 1, 1) \ |
| 403 | V(LoadMessage, Operator::kNoThrow, 0, 1) \ |
| 404 | V(StoreMessage, Operator::kNoThrow, 1, 0) \ |
| 405 | V(StackCheck, Operator::kNoProperties, 0, 0) \ |
| 406 | V(CreateWithContext, Operator::kNoProperties, 2, 1) \ |
| 407 | V(CreateModuleContext, Operator::kNoProperties, 2, 1) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 408 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 409 | struct JSOperatorGlobalCache final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 410 | #define CACHED(Name, properties, value_input_count, value_output_count) \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 411 | struct Name##Operator final : public Operator { \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 412 | Name##Operator() \ |
| 413 | : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ |
| 414 | value_input_count, Operator::ZeroIfPure(properties), \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 415 | Operator::ZeroIfEliminatable(properties), \ |
| 416 | value_output_count, Operator::ZeroIfPure(properties), \ |
| 417 | Operator::ZeroIfNoThrow(properties)) {} \ |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 418 | }; \ |
| 419 | Name##Operator k##Name##Operator; |
| 420 | CACHED_OP_LIST(CACHED) |
| 421 | #undef CACHED |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 422 | }; |
| 423 | |
| 424 | |
| 425 | static base::LazyInstance<JSOperatorGlobalCache>::type kCache = |
| 426 | LAZY_INSTANCE_INITIALIZER; |
| 427 | |
| 428 | |
| 429 | JSOperatorBuilder::JSOperatorBuilder(Zone* zone) |
| 430 | : cache_(kCache.Get()), zone_(zone) {} |
| 431 | |
| 432 | |
| 433 | #define CACHED(Name, properties, value_input_count, value_output_count) \ |
| 434 | const Operator* JSOperatorBuilder::Name() { \ |
| 435 | return &cache_.k##Name##Operator; \ |
| 436 | } |
| 437 | CACHED_OP_LIST(CACHED) |
| 438 | #undef CACHED |
| 439 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 440 | const Operator* JSOperatorBuilder::BitwiseOr(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 441 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 442 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 443 | IrOpcode::kJSBitwiseOr, Operator::kNoProperties, // opcode |
| 444 | "JSBitwiseOr", // name |
| 445 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 446 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 449 | const Operator* JSOperatorBuilder::BitwiseXor(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 450 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 451 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 452 | IrOpcode::kJSBitwiseXor, Operator::kNoProperties, // opcode |
| 453 | "JSBitwiseXor", // name |
| 454 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 455 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 456 | } |
| 457 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 458 | const Operator* JSOperatorBuilder::BitwiseAnd(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 459 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 460 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 461 | IrOpcode::kJSBitwiseAnd, Operator::kNoProperties, // opcode |
| 462 | "JSBitwiseAnd", // name |
| 463 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 464 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 465 | } |
| 466 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 467 | const Operator* JSOperatorBuilder::ShiftLeft(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 468 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 469 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 470 | IrOpcode::kJSShiftLeft, Operator::kNoProperties, // opcode |
| 471 | "JSShiftLeft", // name |
| 472 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 473 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 474 | } |
| 475 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 476 | const Operator* JSOperatorBuilder::ShiftRight(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 477 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 478 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 479 | IrOpcode::kJSShiftRight, Operator::kNoProperties, // opcode |
| 480 | "JSShiftRight", // name |
| 481 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 482 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 483 | } |
| 484 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 485 | const Operator* JSOperatorBuilder::ShiftRightLogical( |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 486 | BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 487 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 488 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 489 | IrOpcode::kJSShiftRightLogical, Operator::kNoProperties, // opcode |
| 490 | "JSShiftRightLogical", // name |
| 491 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 492 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 493 | } |
| 494 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 495 | const Operator* JSOperatorBuilder::Add(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 496 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 497 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 498 | IrOpcode::kJSAdd, Operator::kNoProperties, // opcode |
| 499 | "JSAdd", // name |
| 500 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 501 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 502 | } |
| 503 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 504 | const Operator* JSOperatorBuilder::Subtract(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 505 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 506 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 507 | IrOpcode::kJSSubtract, Operator::kNoProperties, // opcode |
| 508 | "JSSubtract", // name |
| 509 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 510 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 511 | } |
| 512 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 513 | const Operator* JSOperatorBuilder::Multiply(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 514 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 515 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 516 | IrOpcode::kJSMultiply, Operator::kNoProperties, // opcode |
| 517 | "JSMultiply", // name |
| 518 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 519 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 522 | const Operator* JSOperatorBuilder::Divide(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 523 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 524 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 525 | IrOpcode::kJSDivide, Operator::kNoProperties, // opcode |
| 526 | "JSDivide", // name |
| 527 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 528 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 529 | } |
| 530 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 531 | const Operator* JSOperatorBuilder::Modulus(BinaryOperationHints hints) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 532 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 533 | return new (zone()) Operator1<BinaryOperationHints>( //-- |
| 534 | IrOpcode::kJSModulus, Operator::kNoProperties, // opcode |
| 535 | "JSModulus", // name |
| 536 | 2, 1, 1, 1, 1, 2, // inputs/outputs |
| 537 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | |
| 541 | const Operator* JSOperatorBuilder::ToBoolean(ToBooleanHints hints) { |
| 542 | // TODO(turbofan): Cache most important versions of this operator. |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 543 | return new (zone()) Operator1<ToBooleanHints>( //-- |
| 544 | IrOpcode::kJSToBoolean, Operator::kPure, // opcode |
| 545 | "JSToBoolean", // name |
| 546 | 1, 0, 0, 1, 0, 0, // inputs/outputs |
| 547 | hints); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 550 | const Operator* JSOperatorBuilder::CallFunction( |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 551 | size_t arity, VectorSlotPair const& feedback, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 552 | ConvertReceiverMode convert_mode, TailCallMode tail_call_mode) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 553 | CallFunctionParameters parameters(arity, feedback, tail_call_mode, |
| 554 | convert_mode); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 555 | return new (zone()) Operator1<CallFunctionParameters>( // -- |
| 556 | IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode |
| 557 | "JSCallFunction", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 558 | parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 559 | parameters); // parameter |
| 560 | } |
| 561 | |
| 562 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 563 | const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { |
| 564 | const Runtime::Function* f = Runtime::FunctionForId(id); |
| 565 | return CallRuntime(f, f->nargs); |
| 566 | } |
| 567 | |
| 568 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 569 | const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id, |
| 570 | size_t arity) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 571 | const Runtime::Function* f = Runtime::FunctionForId(id); |
| 572 | return CallRuntime(f, arity); |
| 573 | } |
| 574 | |
| 575 | |
| 576 | const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f, |
| 577 | size_t arity) { |
| 578 | CallRuntimeParameters parameters(f->function_id, arity); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 579 | DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); |
| 580 | return new (zone()) Operator1<CallRuntimeParameters>( // -- |
| 581 | IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode |
| 582 | "JSCallRuntime", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 583 | parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 584 | parameters); // parameter |
| 585 | } |
| 586 | |
| 587 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 588 | const Operator* JSOperatorBuilder::CallConstruct( |
| 589 | size_t arity, VectorSlotPair const& feedback) { |
| 590 | CallConstructParameters parameters(arity, feedback); |
| 591 | return new (zone()) Operator1<CallConstructParameters>( // -- |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 592 | IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode |
| 593 | "JSCallConstruct", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 594 | parameters.arity(), 1, 1, 1, 1, 2, // counts |
| 595 | parameters); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 599 | const Operator* JSOperatorBuilder::ConvertReceiver( |
| 600 | ConvertReceiverMode convert_mode) { |
| 601 | return new (zone()) Operator1<ConvertReceiverMode>( // -- |
| 602 | IrOpcode::kJSConvertReceiver, Operator::kNoThrow, // opcode |
| 603 | "JSConvertReceiver", // name |
| 604 | 1, 1, 1, 1, 1, 0, // counts |
| 605 | convert_mode); // parameter |
| 606 | } |
| 607 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 608 | const Operator* JSOperatorBuilder::LoadNamed(Handle<Name> name, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 609 | const VectorSlotPair& feedback) { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 610 | NamedAccess access(SLOPPY, name, feedback); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 611 | return new (zone()) Operator1<NamedAccess>( // -- |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 612 | IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode |
| 613 | "JSLoadNamed", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 614 | 2, 1, 1, 1, 1, 2, // counts |
| 615 | access); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 616 | } |
| 617 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 618 | const Operator* JSOperatorBuilder::LoadProperty( |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 619 | VectorSlotPair const& feedback) { |
| 620 | PropertyAccess access(SLOPPY, feedback); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 621 | return new (zone()) Operator1<PropertyAccess>( // -- |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 622 | IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode |
| 623 | "JSLoadProperty", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 624 | 3, 1, 1, 1, 1, 2, // counts |
| 625 | access); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 629 | const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, |
| 630 | Handle<Name> name, |
| 631 | VectorSlotPair const& feedback) { |
| 632 | NamedAccess access(language_mode, name, feedback); |
| 633 | return new (zone()) Operator1<NamedAccess>( // -- |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 634 | IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode |
| 635 | "JSStoreNamed", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 636 | 3, 1, 1, 0, 1, 2, // counts |
| 637 | access); // parameter |
| 638 | } |
| 639 | |
| 640 | |
| 641 | const Operator* JSOperatorBuilder::StoreProperty( |
| 642 | LanguageMode language_mode, VectorSlotPair const& feedback) { |
| 643 | PropertyAccess access(language_mode, feedback); |
| 644 | return new (zone()) Operator1<PropertyAccess>( // -- |
| 645 | IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode |
| 646 | "JSStoreProperty", // name |
| 647 | 4, 1, 1, 0, 1, 2, // counts |
| 648 | access); // parameter |
| 649 | } |
| 650 | |
| 651 | |
| 652 | const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { |
| 653 | return new (zone()) Operator1<LanguageMode>( // -- |
| 654 | IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode |
| 655 | "JSDeleteProperty", // name |
| 656 | 2, 1, 1, 1, 1, 2, // counts |
| 657 | language_mode); // parameter |
| 658 | } |
| 659 | |
| 660 | |
| 661 | const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name, |
| 662 | const VectorSlotPair& feedback, |
| 663 | TypeofMode typeof_mode) { |
| 664 | LoadGlobalParameters parameters(name, feedback, typeof_mode); |
| 665 | return new (zone()) Operator1<LoadGlobalParameters>( // -- |
| 666 | IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode |
| 667 | "JSLoadGlobal", // name |
| 668 | 1, 1, 1, 1, 1, 2, // counts |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 669 | parameters); // parameter |
| 670 | } |
| 671 | |
| 672 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 673 | const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode, |
| 674 | const Handle<Name>& name, |
| 675 | const VectorSlotPair& feedback) { |
| 676 | StoreGlobalParameters parameters(language_mode, feedback, name); |
| 677 | return new (zone()) Operator1<StoreGlobalParameters>( // -- |
| 678 | IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode |
| 679 | "JSStoreGlobal", // name |
| 680 | 2, 1, 1, 0, 1, 2, // counts |
| 681 | parameters); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | |
| 685 | const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, |
| 686 | bool immutable) { |
| 687 | ContextAccess access(depth, index, immutable); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 688 | return new (zone()) Operator1<ContextAccess>( // -- |
| 689 | IrOpcode::kJSLoadContext, // opcode |
| 690 | Operator::kNoWrite | Operator::kNoThrow, // flags |
| 691 | "JSLoadContext", // name |
| 692 | 1, 1, 0, 1, 1, 0, // counts |
| 693 | access); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | |
| 697 | const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) { |
| 698 | ContextAccess access(depth, index, false); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 699 | return new (zone()) Operator1<ContextAccess>( // -- |
| 700 | IrOpcode::kJSStoreContext, // opcode |
| 701 | Operator::kNoRead | Operator::kNoThrow, // flags |
| 702 | "JSStoreContext", // name |
| 703 | 2, 1, 1, 0, 1, 0, // counts |
| 704 | access); // parameter |
| 705 | } |
| 706 | |
| 707 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 708 | const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 709 | return new (zone()) Operator1<CreateArgumentsType>( // -- |
| 710 | IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode |
| 711 | "JSCreateArguments", // name |
| 712 | 1, 1, 0, 1, 1, 0, // counts |
| 713 | type); // parameter |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | |
| 717 | const Operator* JSOperatorBuilder::CreateArray(size_t arity, |
| 718 | Handle<AllocationSite> site) { |
| 719 | // constructor, new_target, arg1, ..., argN |
| 720 | int const value_input_count = static_cast<int>(arity) + 2; |
| 721 | CreateArrayParameters parameters(arity, site); |
| 722 | return new (zone()) Operator1<CreateArrayParameters>( // -- |
| 723 | IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode |
| 724 | "JSCreateArray", // name |
| 725 | value_input_count, 1, 1, 1, 1, 2, // counts |
| 726 | parameters); // parameter |
| 727 | } |
| 728 | |
| 729 | |
| 730 | const Operator* JSOperatorBuilder::CreateClosure( |
| 731 | Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { |
| 732 | CreateClosureParameters parameters(shared_info, pretenure); |
| 733 | return new (zone()) Operator1<CreateClosureParameters>( // -- |
| 734 | IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode |
| 735 | "JSCreateClosure", // name |
| 736 | 0, 1, 1, 1, 1, 0, // counts |
| 737 | parameters); // parameter |
| 738 | } |
| 739 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 740 | const Operator* JSOperatorBuilder::CreateLiteralArray( |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 741 | Handle<FixedArray> constant_elements, int literal_flags, int literal_index, |
| 742 | int number_of_elements) { |
| 743 | CreateLiteralParameters parameters(constant_elements, number_of_elements, |
| 744 | literal_flags, literal_index); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 745 | return new (zone()) Operator1<CreateLiteralParameters>( // -- |
| 746 | IrOpcode::kJSCreateLiteralArray, Operator::kNoProperties, // opcode |
| 747 | "JSCreateLiteralArray", // name |
| 748 | 1, 1, 1, 1, 1, 2, // counts |
| 749 | parameters); // parameter |
| 750 | } |
| 751 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 752 | const Operator* JSOperatorBuilder::CreateLiteralObject( |
| 753 | Handle<FixedArray> constant_properties, int literal_flags, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 754 | int literal_index, int number_of_properties) { |
| 755 | CreateLiteralParameters parameters(constant_properties, number_of_properties, |
| 756 | literal_flags, literal_index); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 757 | return new (zone()) Operator1<CreateLiteralParameters>( // -- |
| 758 | IrOpcode::kJSCreateLiteralObject, Operator::kNoProperties, // opcode |
| 759 | "JSCreateLiteralObject", // name |
| 760 | 1, 1, 1, 1, 1, 2, // counts |
| 761 | parameters); // parameter |
| 762 | } |
| 763 | |
| 764 | |
| 765 | const Operator* JSOperatorBuilder::CreateLiteralRegExp( |
| 766 | Handle<String> constant_pattern, int literal_flags, int literal_index) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 767 | CreateLiteralParameters parameters(constant_pattern, -1, literal_flags, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 768 | literal_index); |
| 769 | return new (zone()) Operator1<CreateLiteralParameters>( // -- |
| 770 | IrOpcode::kJSCreateLiteralRegExp, Operator::kNoProperties, // opcode |
| 771 | "JSCreateLiteralRegExp", // name |
| 772 | 1, 1, 1, 1, 1, 2, // counts |
| 773 | parameters); // parameter |
| 774 | } |
| 775 | |
| 776 | |
| 777 | const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count) { |
| 778 | return new (zone()) Operator1<int>( // -- |
| 779 | IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode |
| 780 | "JSCreateFunctionContext", // name |
| 781 | 1, 1, 1, 1, 1, 2, // counts |
| 782 | slot_count); // parameter |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | |
| 786 | const Operator* JSOperatorBuilder::CreateCatchContext( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 787 | const Handle<String>& name) { |
| 788 | return new (zone()) Operator1<Handle<String>>( // -- |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 789 | IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 790 | "JSCreateCatchContext", // name |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 791 | 2, 1, 1, 1, 1, 2, // counts |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 792 | name); // parameter |
| 793 | } |
| 794 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 795 | |
| 796 | const Operator* JSOperatorBuilder::CreateBlockContext( |
| 797 | const Handle<ScopeInfo>& scpope_info) { |
| 798 | return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
| 799 | IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode |
| 800 | "JSCreateBlockContext", // name |
| 801 | 1, 1, 1, 1, 1, 2, // counts |
| 802 | scpope_info); // parameter |
| 803 | } |
| 804 | |
| 805 | |
| 806 | const Operator* JSOperatorBuilder::CreateScriptContext( |
| 807 | const Handle<ScopeInfo>& scpope_info) { |
| 808 | return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
| 809 | IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
| 810 | "JSCreateScriptContext", // name |
| 811 | 1, 1, 1, 1, 1, 2, // counts |
| 812 | scpope_info); // parameter |
| 813 | } |
| 814 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 815 | } // namespace compiler |
| 816 | } // namespace internal |
| 817 | } // namespace v8 |