OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // GC. This means that we must be statically sure that no GC can occur while | 155 // GC. This means that we must be statically sure that no GC can occur while |
156 // they are running. If that is the case they should override this to return | 156 // they are running. If that is the case they should override this to return |
157 // true, which will cause an assertion if we try to call something that can | 157 // true, which will cause an assertion if we try to call something that can |
158 // GC or if we try to put a stack frame on top of the junk, which would not | 158 // GC or if we try to put a stack frame on top of the junk, which would not |
159 // result in a traversable stack. | 159 // result in a traversable stack. |
160 virtual bool SometimesSetsUpAFrame() { return true; } | 160 virtual bool SometimesSetsUpAFrame() { return true; } |
161 | 161 |
162 // Lookup the code in the (possibly custom) cache. | 162 // Lookup the code in the (possibly custom) cache. |
163 bool FindCodeInCache(Code** code_out, Isolate* isolate); | 163 bool FindCodeInCache(Code** code_out, Isolate* isolate); |
164 | 164 |
| 165 // Returns information for computing the number key. |
| 166 virtual Major MajorKey() = 0; |
| 167 virtual int MinorKey() = 0; |
| 168 |
165 protected: | 169 protected: |
166 static bool CanUseFPRegisters(); | 170 static bool CanUseFPRegisters(); |
167 | 171 |
| 172 // Generates the assembler code for the stub. |
| 173 virtual Handle<Code> GenerateCode() = 0; |
| 174 |
| 175 // BinaryOpStub needs to override this. |
| 176 virtual InlineCacheState GetICState() { |
| 177 return UNINITIALIZED; |
| 178 } |
| 179 |
| 180 // Returns whether the code generated for this stub needs to be allocated as |
| 181 // a fixed (non-moveable) code object. |
| 182 virtual bool NeedsImmovableCode() { return false; } |
| 183 |
168 private: | 184 private: |
169 // Nonvirtual wrapper around the stub-specific Generate function. Call | |
170 // this function to set up the macro assembler and generate the code. | |
171 void GenerateCode(MacroAssembler* masm); | |
172 | |
173 // Generates the assembler code for the stub. | |
174 virtual void Generate(MacroAssembler* masm) = 0; | |
175 | |
176 // Perform bookkeeping required after code generation when stub code is | 185 // Perform bookkeeping required after code generation when stub code is |
177 // initially generated. | 186 // initially generated. |
178 void RecordCodeGeneration(Code* code, MacroAssembler* masm); | 187 void RecordCodeGeneration(Code* code, Isolate* isolate); |
179 | 188 |
180 // Finish the code object after it has been generated. | 189 // Finish the code object after it has been generated. |
181 virtual void FinishCode(Handle<Code> code) { } | 190 virtual void FinishCode(Handle<Code> code) { } |
182 | 191 |
183 // Activate newly generated stub. Is called after | 192 // Activate newly generated stub. Is called after |
184 // registering stub in the stub cache. | 193 // registering stub in the stub cache. |
185 virtual void Activate(Code* code) { } | 194 virtual void Activate(Code* code) { } |
186 | 195 |
187 // Returns information for computing the number key. | |
188 virtual Major MajorKey() = 0; | |
189 virtual int MinorKey() = 0; | |
190 | |
191 // BinaryOpStub needs to override this. | 196 // BinaryOpStub needs to override this. |
192 virtual int GetCodeKind(); | 197 virtual int GetCodeKind(); |
193 | 198 |
194 // BinaryOpStub needs to override this. | |
195 virtual InlineCacheState GetICState() { | |
196 return UNINITIALIZED; | |
197 } | |
198 | |
199 // Add the code to a specialized cache, specific to an individual | 199 // Add the code to a specialized cache, specific to an individual |
200 // stub type. Please note, this method must add the code object to a | 200 // stub type. Please note, this method must add the code object to a |
201 // roots object, otherwise we will remove the code during GC. | 201 // roots object, otherwise we will remove the code during GC. |
202 virtual void AddToSpecialCache(Handle<Code> new_object) { } | 202 virtual void AddToSpecialCache(Handle<Code> new_object) { } |
203 | 203 |
204 // Find code in a specialized cache, work is delegated to the specific stub. | 204 // Find code in a specialized cache, work is delegated to the specific stub. |
205 virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { | 205 virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 | 208 |
209 // If a stub uses a special cache override this. | 209 // If a stub uses a special cache override this. |
210 virtual bool UseSpecialCache() { return false; } | 210 virtual bool UseSpecialCache() { return false; } |
211 | 211 |
212 // Returns a name for logging/debugging purposes. | 212 // Returns a name for logging/debugging purposes. |
213 SmartArrayPointer<const char> GetName(); | 213 SmartArrayPointer<const char> GetName(); |
214 virtual void PrintName(StringStream* stream); | 214 virtual void PrintName(StringStream* stream); |
215 | 215 |
216 // Returns whether the code generated for this stub needs to be allocated as | |
217 // a fixed (non-moveable) code object. | |
218 virtual bool NeedsImmovableCode() { return false; } | |
219 | |
220 // Computes the key based on major and minor. | 216 // Computes the key based on major and minor. |
221 uint32_t GetKey() { | 217 uint32_t GetKey() { |
222 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); | 218 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS); |
223 return MinorKeyBits::encode(MinorKey()) | | 219 return MinorKeyBits::encode(MinorKey()) | |
224 MajorKeyBits::encode(MajorKey()); | 220 MajorKeyBits::encode(MajorKey()); |
225 } | 221 } |
226 | 222 |
227 class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; | 223 class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {}; |
228 class MinorKeyBits: public BitField<uint32_t, | 224 class MinorKeyBits: public BitField<uint32_t, |
229 kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT | 225 kStubMajorKeyBits, kStubMinorKeyBits> {}; // NOLINT |
230 | 226 |
231 friend class BreakPointIterator; | 227 friend class BreakPointIterator; |
232 }; | 228 }; |
233 | 229 |
234 | 230 |
| 231 class PlatformCodeStub : public CodeStub { |
| 232 public: |
| 233 // Retrieve the code for the stub. Generate the code if needed. |
| 234 virtual Handle<Code> GenerateCode(); |
| 235 |
| 236 virtual int GetCodeKind() { return Code::STUB; } |
| 237 |
| 238 protected: |
| 239 // Generates the assembler code for the stub. |
| 240 virtual void Generate(MacroAssembler* masm) = 0; |
| 241 }; |
| 242 |
| 243 |
| 244 struct CodeStubInterfaceDescriptor { |
| 245 int number_of_register_params; |
| 246 Register* register_params; |
| 247 Handle<Code> deoptimization_handler; |
| 248 }; |
| 249 |
| 250 |
| 251 class HGraph; |
| 252 struct Register; |
| 253 class HydrogenCodeStub : public CodeStub { |
| 254 public: |
| 255 // Retrieve the code for the stub. Generate the code if needed. |
| 256 virtual Handle<Code> GenerateCode() = 0; |
| 257 |
| 258 virtual int GetCodeKind() { return Code::COMPILED_STUB; } |
| 259 |
| 260 virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor( |
| 261 Isolate* isolate) = 0; |
| 262 |
| 263 protected: |
| 264 Handle<Code> CodeFromGraph(HGraph* graph); |
| 265 }; |
| 266 |
| 267 |
235 // Helper interface to prepare to/restore after making runtime calls. | 268 // Helper interface to prepare to/restore after making runtime calls. |
236 class RuntimeCallHelper { | 269 class RuntimeCallHelper { |
237 public: | 270 public: |
238 virtual ~RuntimeCallHelper() {} | 271 virtual ~RuntimeCallHelper() {} |
239 | 272 |
240 virtual void BeforeCall(MacroAssembler* masm) const = 0; | 273 virtual void BeforeCall(MacroAssembler* masm) const = 0; |
241 | 274 |
242 virtual void AfterCall(MacroAssembler* masm) const = 0; | 275 virtual void AfterCall(MacroAssembler* masm) const = 0; |
243 | 276 |
244 protected: | 277 protected: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 class NopRuntimeCallHelper : public RuntimeCallHelper { | 315 class NopRuntimeCallHelper : public RuntimeCallHelper { |
283 public: | 316 public: |
284 NopRuntimeCallHelper() {} | 317 NopRuntimeCallHelper() {} |
285 | 318 |
286 virtual void BeforeCall(MacroAssembler* masm) const {} | 319 virtual void BeforeCall(MacroAssembler* masm) const {} |
287 | 320 |
288 virtual void AfterCall(MacroAssembler* masm) const {} | 321 virtual void AfterCall(MacroAssembler* masm) const {} |
289 }; | 322 }; |
290 | 323 |
291 | 324 |
292 class StackCheckStub : public CodeStub { | 325 class StackCheckStub : public PlatformCodeStub { |
293 public: | 326 public: |
294 StackCheckStub() { } | 327 StackCheckStub() { } |
295 | 328 |
296 void Generate(MacroAssembler* masm); | 329 void Generate(MacroAssembler* masm); |
297 | 330 |
298 private: | 331 private: |
299 Major MajorKey() { return StackCheck; } | 332 Major MajorKey() { return StackCheck; } |
300 int MinorKey() { return 0; } | 333 int MinorKey() { return 0; } |
301 }; | 334 }; |
302 | 335 |
303 | 336 |
304 class InterruptStub : public CodeStub { | 337 class InterruptStub : public PlatformCodeStub { |
305 public: | 338 public: |
306 InterruptStub() { } | 339 InterruptStub() { } |
307 | 340 |
308 void Generate(MacroAssembler* masm); | 341 void Generate(MacroAssembler* masm); |
309 | 342 |
310 private: | 343 private: |
311 Major MajorKey() { return Interrupt; } | 344 Major MajorKey() { return Interrupt; } |
312 int MinorKey() { return 0; } | 345 int MinorKey() { return 0; } |
313 }; | 346 }; |
314 | 347 |
315 | 348 |
316 class ToNumberStub: public CodeStub { | 349 class ToNumberStub: public PlatformCodeStub { |
317 public: | 350 public: |
318 ToNumberStub() { } | 351 ToNumberStub() { } |
319 | 352 |
320 void Generate(MacroAssembler* masm); | 353 void Generate(MacroAssembler* masm); |
321 | 354 |
322 private: | 355 private: |
323 Major MajorKey() { return ToNumber; } | 356 Major MajorKey() { return ToNumber; } |
324 int MinorKey() { return 0; } | 357 int MinorKey() { return 0; } |
325 }; | 358 }; |
326 | 359 |
327 | 360 |
328 class FastNewClosureStub : public CodeStub { | 361 class FastNewClosureStub : public PlatformCodeStub { |
329 public: | 362 public: |
330 explicit FastNewClosureStub(LanguageMode language_mode) | 363 explicit FastNewClosureStub(LanguageMode language_mode) |
331 : language_mode_(language_mode) { } | 364 : language_mode_(language_mode) { } |
332 | 365 |
333 void Generate(MacroAssembler* masm); | 366 void Generate(MacroAssembler* masm); |
334 | 367 |
335 private: | 368 private: |
336 Major MajorKey() { return FastNewClosure; } | 369 Major MajorKey() { return FastNewClosure; } |
337 int MinorKey() { return language_mode_ == CLASSIC_MODE | 370 int MinorKey() { return language_mode_ == CLASSIC_MODE |
338 ? kNonStrictMode : kStrictMode; } | 371 ? kNonStrictMode : kStrictMode; } |
339 | 372 |
340 LanguageMode language_mode_; | 373 LanguageMode language_mode_; |
341 }; | 374 }; |
342 | 375 |
343 | 376 |
344 class FastNewContextStub : public CodeStub { | 377 class FastNewContextStub : public PlatformCodeStub { |
345 public: | 378 public: |
346 static const int kMaximumSlots = 64; | 379 static const int kMaximumSlots = 64; |
347 | 380 |
348 explicit FastNewContextStub(int slots) : slots_(slots) { | 381 explicit FastNewContextStub(int slots) : slots_(slots) { |
349 ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); | 382 ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); |
350 } | 383 } |
351 | 384 |
352 void Generate(MacroAssembler* masm); | 385 void Generate(MacroAssembler* masm); |
353 | 386 |
354 private: | 387 private: |
355 int slots_; | 388 int slots_; |
356 | 389 |
357 Major MajorKey() { return FastNewContext; } | 390 Major MajorKey() { return FastNewContext; } |
358 int MinorKey() { return slots_; } | 391 int MinorKey() { return slots_; } |
359 }; | 392 }; |
360 | 393 |
361 | 394 |
362 class FastNewBlockContextStub : public CodeStub { | 395 class FastNewBlockContextStub : public PlatformCodeStub { |
363 public: | 396 public: |
364 static const int kMaximumSlots = 64; | 397 static const int kMaximumSlots = 64; |
365 | 398 |
366 explicit FastNewBlockContextStub(int slots) : slots_(slots) { | 399 explicit FastNewBlockContextStub(int slots) : slots_(slots) { |
367 ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); | 400 ASSERT(slots_ > 0 && slots_ <= kMaximumSlots); |
368 } | 401 } |
369 | 402 |
370 void Generate(MacroAssembler* masm); | 403 void Generate(MacroAssembler* masm); |
371 | 404 |
372 private: | 405 private: |
373 int slots_; | 406 int slots_; |
374 | 407 |
375 Major MajorKey() { return FastNewBlockContext; } | 408 Major MajorKey() { return FastNewBlockContext; } |
376 int MinorKey() { return slots_; } | 409 int MinorKey() { return slots_; } |
377 }; | 410 }; |
378 | 411 |
379 | 412 |
380 class FastCloneShallowArrayStub : public CodeStub { | 413 class FastCloneShallowArrayStub : public PlatformCodeStub { |
381 public: | 414 public: |
382 // Maximum length of copied elements array. | 415 // Maximum length of copied elements array. |
383 static const int kMaximumClonedLength = 8; | 416 static const int kMaximumClonedLength = 8; |
384 | 417 |
385 enum Mode { | 418 enum Mode { |
386 CLONE_ELEMENTS, | 419 CLONE_ELEMENTS, |
387 CLONE_DOUBLE_ELEMENTS, | 420 CLONE_DOUBLE_ELEMENTS, |
388 COPY_ON_WRITE_ELEMENTS, | 421 COPY_ON_WRITE_ELEMENTS, |
389 CLONE_ANY_ELEMENTS | 422 CLONE_ANY_ELEMENTS |
390 }; | 423 }; |
(...skipping 12 matching lines...) Expand all Loading... |
403 int length_; | 436 int length_; |
404 | 437 |
405 Major MajorKey() { return FastCloneShallowArray; } | 438 Major MajorKey() { return FastCloneShallowArray; } |
406 int MinorKey() { | 439 int MinorKey() { |
407 ASSERT(mode_ == 0 || mode_ == 1 || mode_ == 2 || mode_ == 3); | 440 ASSERT(mode_ == 0 || mode_ == 1 || mode_ == 2 || mode_ == 3); |
408 return length_ * 4 + mode_; | 441 return length_ * 4 + mode_; |
409 } | 442 } |
410 }; | 443 }; |
411 | 444 |
412 | 445 |
413 class FastCloneShallowObjectStub : public CodeStub { | 446 class FastCloneShallowObjectStub : public PlatformCodeStub { |
414 public: | 447 public: |
415 // Maximum number of properties in copied object. | 448 // Maximum number of properties in copied object. |
416 static const int kMaximumClonedProperties = 6; | 449 static const int kMaximumClonedProperties = 6; |
417 | 450 |
418 explicit FastCloneShallowObjectStub(int length) : length_(length) { | 451 explicit FastCloneShallowObjectStub(int length) : length_(length) { |
419 ASSERT_GE(length_, 0); | 452 ASSERT_GE(length_, 0); |
420 ASSERT_LE(length_, kMaximumClonedProperties); | 453 ASSERT_LE(length_, kMaximumClonedProperties); |
421 } | 454 } |
422 | 455 |
423 void Generate(MacroAssembler* masm); | 456 void Generate(MacroAssembler* masm); |
424 | 457 |
425 private: | 458 private: |
426 int length_; | 459 int length_; |
427 | 460 |
428 Major MajorKey() { return FastCloneShallowObject; } | 461 Major MajorKey() { return FastCloneShallowObject; } |
429 int MinorKey() { return length_; } | 462 int MinorKey() { return length_; } |
430 }; | 463 }; |
431 | 464 |
432 | 465 |
433 class InstanceofStub: public CodeStub { | 466 class InstanceofStub: public PlatformCodeStub { |
434 public: | 467 public: |
435 enum Flags { | 468 enum Flags { |
436 kNoFlags = 0, | 469 kNoFlags = 0, |
437 kArgsInRegisters = 1 << 0, | 470 kArgsInRegisters = 1 << 0, |
438 kCallSiteInlineCheck = 1 << 1, | 471 kCallSiteInlineCheck = 1 << 1, |
439 kReturnTrueFalseObject = 1 << 2 | 472 kReturnTrueFalseObject = 1 << 2 |
440 }; | 473 }; |
441 | 474 |
442 explicit InstanceofStub(Flags flags) : flags_(flags) { } | 475 explicit InstanceofStub(Flags flags) : flags_(flags) { } |
443 | 476 |
(...skipping 17 matching lines...) Expand all Loading... |
461 bool ReturnTrueFalseObject() const { | 494 bool ReturnTrueFalseObject() const { |
462 return (flags_ & kReturnTrueFalseObject) != 0; | 495 return (flags_ & kReturnTrueFalseObject) != 0; |
463 } | 496 } |
464 | 497 |
465 virtual void PrintName(StringStream* stream); | 498 virtual void PrintName(StringStream* stream); |
466 | 499 |
467 Flags flags_; | 500 Flags flags_; |
468 }; | 501 }; |
469 | 502 |
470 | 503 |
471 class MathPowStub: public CodeStub { | 504 class MathPowStub: public PlatformCodeStub { |
472 public: | 505 public: |
473 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; | 506 enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; |
474 | 507 |
475 explicit MathPowStub(ExponentType exponent_type) | 508 explicit MathPowStub(ExponentType exponent_type) |
476 : exponent_type_(exponent_type) { } | 509 : exponent_type_(exponent_type) { } |
477 virtual void Generate(MacroAssembler* masm); | 510 virtual void Generate(MacroAssembler* masm); |
478 | 511 |
479 private: | 512 private: |
480 virtual CodeStub::Major MajorKey() { return MathPow; } | 513 virtual CodeStub::Major MajorKey() { return MathPow; } |
481 virtual int MinorKey() { return exponent_type_; } | 514 virtual int MinorKey() { return exponent_type_; } |
482 | 515 |
483 ExponentType exponent_type_; | 516 ExponentType exponent_type_; |
484 }; | 517 }; |
485 | 518 |
486 | 519 |
487 class BinaryOpStub: public CodeStub { | 520 class BinaryOpStub: public PlatformCodeStub { |
488 public: | 521 public: |
489 BinaryOpStub(Token::Value op, OverwriteMode mode) | 522 BinaryOpStub(Token::Value op, OverwriteMode mode) |
490 : op_(op), | 523 : op_(op), |
491 mode_(mode), | 524 mode_(mode), |
492 platform_specific_bit_(false), | 525 platform_specific_bit_(false), |
493 left_type_(BinaryOpIC::UNINITIALIZED), | 526 left_type_(BinaryOpIC::UNINITIALIZED), |
494 right_type_(BinaryOpIC::UNINITIALIZED), | 527 right_type_(BinaryOpIC::UNINITIALIZED), |
495 result_type_(BinaryOpIC::UNINITIALIZED) { | 528 result_type_(BinaryOpIC::UNINITIALIZED) { |
496 Initialize(); | 529 Initialize(); |
497 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 530 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 } | 626 } |
594 | 627 |
595 virtual void FinishCode(Handle<Code> code) { | 628 virtual void FinishCode(Handle<Code> code) { |
596 code->set_stub_info(MinorKey()); | 629 code->set_stub_info(MinorKey()); |
597 } | 630 } |
598 | 631 |
599 friend class CodeGenerator; | 632 friend class CodeGenerator; |
600 }; | 633 }; |
601 | 634 |
602 | 635 |
603 class ICCompareStub: public CodeStub { | 636 class ICCompareStub: public PlatformCodeStub { |
604 public: | 637 public: |
605 ICCompareStub(Token::Value op, | 638 ICCompareStub(Token::Value op, |
606 CompareIC::State left, | 639 CompareIC::State left, |
607 CompareIC::State right, | 640 CompareIC::State right, |
608 CompareIC::State handler) | 641 CompareIC::State handler) |
609 : op_(op), | 642 : op_(op), |
610 left_(left), | 643 left_(left), |
611 right_(right), | 644 right_(right), |
612 state_(handler) { | 645 state_(handler) { |
613 ASSERT(Token::IsCompareOp(op)); | 646 ASSERT(Token::IsCompareOp(op)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECTS; } | 692 virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECTS; } |
660 | 693 |
661 Token::Value op_; | 694 Token::Value op_; |
662 CompareIC::State left_; | 695 CompareIC::State left_; |
663 CompareIC::State right_; | 696 CompareIC::State right_; |
664 CompareIC::State state_; | 697 CompareIC::State state_; |
665 Handle<Map> known_map_; | 698 Handle<Map> known_map_; |
666 }; | 699 }; |
667 | 700 |
668 | 701 |
669 class CEntryStub : public CodeStub { | 702 class CEntryStub : public PlatformCodeStub { |
670 public: | 703 public: |
671 explicit CEntryStub(int result_size, | 704 explicit CEntryStub(int result_size, |
672 SaveFPRegsMode save_doubles = kDontSaveFPRegs) | 705 SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
673 : result_size_(result_size), save_doubles_(save_doubles) { } | 706 : result_size_(result_size), save_doubles_(save_doubles) { } |
674 | 707 |
675 void Generate(MacroAssembler* masm); | 708 void Generate(MacroAssembler* masm); |
676 | 709 |
677 // The version of this stub that doesn't save doubles is generated ahead of | 710 // The version of this stub that doesn't save doubles is generated ahead of |
678 // time, so it's OK to call it from other stubs that can't cope with GC during | 711 // time, so it's OK to call it from other stubs that can't cope with GC during |
679 // their code generation. On machines that always have gp registers (x64) we | 712 // their code generation. On machines that always have gp registers (x64) we |
(...skipping 13 matching lines...) Expand all Loading... |
693 const int result_size_; | 726 const int result_size_; |
694 SaveFPRegsMode save_doubles_; | 727 SaveFPRegsMode save_doubles_; |
695 | 728 |
696 Major MajorKey() { return CEntry; } | 729 Major MajorKey() { return CEntry; } |
697 int MinorKey(); | 730 int MinorKey(); |
698 | 731 |
699 bool NeedsImmovableCode(); | 732 bool NeedsImmovableCode(); |
700 }; | 733 }; |
701 | 734 |
702 | 735 |
703 class JSEntryStub : public CodeStub { | 736 class JSEntryStub : public PlatformCodeStub { |
704 public: | 737 public: |
705 JSEntryStub() { } | 738 JSEntryStub() { } |
706 | 739 |
707 void Generate(MacroAssembler* masm) { GenerateBody(masm, false); } | 740 void Generate(MacroAssembler* masm) { GenerateBody(masm, false); } |
708 | 741 |
709 protected: | 742 protected: |
710 void GenerateBody(MacroAssembler* masm, bool is_construct); | 743 void GenerateBody(MacroAssembler* masm, bool is_construct); |
711 | 744 |
712 private: | 745 private: |
713 Major MajorKey() { return JSEntry; } | 746 Major MajorKey() { return JSEntry; } |
(...skipping 13 matching lines...) Expand all Loading... |
727 | 760 |
728 private: | 761 private: |
729 int MinorKey() { return 1; } | 762 int MinorKey() { return 1; } |
730 | 763 |
731 virtual void PrintName(StringStream* stream) { | 764 virtual void PrintName(StringStream* stream) { |
732 stream->Add("JSConstructEntryStub"); | 765 stream->Add("JSConstructEntryStub"); |
733 } | 766 } |
734 }; | 767 }; |
735 | 768 |
736 | 769 |
737 class ArgumentsAccessStub: public CodeStub { | 770 class ArgumentsAccessStub: public PlatformCodeStub { |
738 public: | 771 public: |
739 enum Type { | 772 enum Type { |
740 READ_ELEMENT, | 773 READ_ELEMENT, |
741 NEW_NON_STRICT_FAST, | 774 NEW_NON_STRICT_FAST, |
742 NEW_NON_STRICT_SLOW, | 775 NEW_NON_STRICT_SLOW, |
743 NEW_STRICT | 776 NEW_STRICT |
744 }; | 777 }; |
745 | 778 |
746 explicit ArgumentsAccessStub(Type type) : type_(type) { } | 779 explicit ArgumentsAccessStub(Type type) : type_(type) { } |
747 | 780 |
748 private: | 781 private: |
749 Type type_; | 782 Type type_; |
750 | 783 |
751 Major MajorKey() { return ArgumentsAccess; } | 784 Major MajorKey() { return ArgumentsAccess; } |
752 int MinorKey() { return type_; } | 785 int MinorKey() { return type_; } |
753 | 786 |
754 void Generate(MacroAssembler* masm); | 787 void Generate(MacroAssembler* masm); |
755 void GenerateReadElement(MacroAssembler* masm); | 788 void GenerateReadElement(MacroAssembler* masm); |
756 void GenerateNewStrict(MacroAssembler* masm); | 789 void GenerateNewStrict(MacroAssembler* masm); |
757 void GenerateNewNonStrictFast(MacroAssembler* masm); | 790 void GenerateNewNonStrictFast(MacroAssembler* masm); |
758 void GenerateNewNonStrictSlow(MacroAssembler* masm); | 791 void GenerateNewNonStrictSlow(MacroAssembler* masm); |
759 | 792 |
760 virtual void PrintName(StringStream* stream); | 793 virtual void PrintName(StringStream* stream); |
761 }; | 794 }; |
762 | 795 |
763 | 796 |
764 class RegExpExecStub: public CodeStub { | 797 class RegExpExecStub: public PlatformCodeStub { |
765 public: | 798 public: |
766 RegExpExecStub() { } | 799 RegExpExecStub() { } |
767 | 800 |
768 private: | 801 private: |
769 Major MajorKey() { return RegExpExec; } | 802 Major MajorKey() { return RegExpExec; } |
770 int MinorKey() { return 0; } | 803 int MinorKey() { return 0; } |
771 | 804 |
772 void Generate(MacroAssembler* masm); | 805 void Generate(MacroAssembler* masm); |
773 }; | 806 }; |
774 | 807 |
775 | 808 |
776 class RegExpConstructResultStub: public CodeStub { | 809 class RegExpConstructResultStub: public PlatformCodeStub { |
777 public: | 810 public: |
778 RegExpConstructResultStub() { } | 811 RegExpConstructResultStub() { } |
779 | 812 |
780 private: | 813 private: |
781 Major MajorKey() { return RegExpConstructResult; } | 814 Major MajorKey() { return RegExpConstructResult; } |
782 int MinorKey() { return 0; } | 815 int MinorKey() { return 0; } |
783 | 816 |
784 void Generate(MacroAssembler* masm); | 817 void Generate(MacroAssembler* masm); |
785 }; | 818 }; |
786 | 819 |
787 | 820 |
788 class CallFunctionStub: public CodeStub { | 821 class CallFunctionStub: public PlatformCodeStub { |
789 public: | 822 public: |
790 CallFunctionStub(int argc, CallFunctionFlags flags) | 823 CallFunctionStub(int argc, CallFunctionFlags flags) |
791 : argc_(argc), flags_(flags) { } | 824 : argc_(argc), flags_(flags) { } |
792 | 825 |
793 void Generate(MacroAssembler* masm); | 826 void Generate(MacroAssembler* masm); |
794 | 827 |
795 virtual void FinishCode(Handle<Code> code) { | 828 virtual void FinishCode(Handle<Code> code) { |
796 code->set_has_function_cache(RecordCallTarget()); | 829 code->set_has_function_cache(RecordCallTarget()); |
797 } | 830 } |
798 | 831 |
(...skipping 20 matching lines...) Expand all Loading... |
819 bool ReceiverMightBeImplicit() { | 852 bool ReceiverMightBeImplicit() { |
820 return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0; | 853 return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0; |
821 } | 854 } |
822 | 855 |
823 bool RecordCallTarget() { | 856 bool RecordCallTarget() { |
824 return (flags_ & RECORD_CALL_TARGET) != 0; | 857 return (flags_ & RECORD_CALL_TARGET) != 0; |
825 } | 858 } |
826 }; | 859 }; |
827 | 860 |
828 | 861 |
829 class CallConstructStub: public CodeStub { | 862 class CallConstructStub: public PlatformCodeStub { |
830 public: | 863 public: |
831 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} | 864 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} |
832 | 865 |
833 void Generate(MacroAssembler* masm); | 866 void Generate(MacroAssembler* masm); |
834 | 867 |
835 virtual void FinishCode(Handle<Code> code) { | 868 virtual void FinishCode(Handle<Code> code) { |
836 code->set_has_function_cache(RecordCallTarget()); | 869 code->set_has_function_cache(RecordCallTarget()); |
837 } | 870 } |
838 | 871 |
839 private: | 872 private: |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 } | 1043 } |
1011 | 1044 |
1012 private: | 1045 private: |
1013 MacroAssembler* masm_; | 1046 MacroAssembler* masm_; |
1014 bool previous_allow_; | 1047 bool previous_allow_; |
1015 | 1048 |
1016 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); | 1049 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); |
1017 }; | 1050 }; |
1018 | 1051 |
1019 | 1052 |
1020 class KeyedLoadElementStub : public CodeStub { | 1053 class KeyedLoadDictionaryElementStub : public PlatformCodeStub { |
1021 public: | 1054 public: |
1022 explicit KeyedLoadElementStub(ElementsKind elements_kind) | 1055 KeyedLoadDictionaryElementStub() {} |
1023 : elements_kind_(elements_kind) | |
1024 { } | |
1025 | 1056 |
1026 Major MajorKey() { return KeyedLoadElement; } | 1057 Major MajorKey() { return KeyedLoadElement; } |
1027 int MinorKey() { return elements_kind_; } | 1058 int MinorKey() { return DICTIONARY_ELEMENTS; } |
1028 | 1059 |
1029 void Generate(MacroAssembler* masm); | 1060 void Generate(MacroAssembler* masm); |
1030 | 1061 |
1031 private: | 1062 private: |
1032 ElementsKind elements_kind_; | 1063 DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementStub); |
1033 | |
1034 DISALLOW_COPY_AND_ASSIGN(KeyedLoadElementStub); | |
1035 }; | 1064 }; |
1036 | 1065 |
1037 | 1066 |
1038 class KeyedStoreElementStub : public CodeStub { | 1067 class KeyedLoadFastElementStub : public HydrogenCodeStub { |
| 1068 public: |
| 1069 KeyedLoadFastElementStub(bool is_js_array, ElementsKind elements_kind) { |
| 1070 bit_field_ = ElementsKindBits::encode(elements_kind) | |
| 1071 IsJSArrayBits::encode(is_js_array); |
| 1072 } |
| 1073 |
| 1074 Major MajorKey() { return KeyedLoadElement; } |
| 1075 int MinorKey() { return bit_field_; } |
| 1076 |
| 1077 bool is_js_array() const { |
| 1078 return IsJSArrayBits::decode(bit_field_); |
| 1079 } |
| 1080 |
| 1081 ElementsKind elements_kind() const { |
| 1082 return ElementsKindBits::decode(bit_field_); |
| 1083 } |
| 1084 |
| 1085 virtual Handle<Code> GenerateCode(); |
| 1086 |
| 1087 virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor( |
| 1088 Isolate* isolate); |
| 1089 |
| 1090 private: |
| 1091 class IsJSArrayBits: public BitField<bool, 8, 1> {}; |
| 1092 class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
| 1093 uint32_t bit_field_; |
| 1094 |
| 1095 DISALLOW_COPY_AND_ASSIGN(KeyedLoadFastElementStub); |
| 1096 }; |
| 1097 |
| 1098 |
| 1099 class KeyedStoreElementStub : public PlatformCodeStub { |
1039 public: | 1100 public: |
1040 KeyedStoreElementStub(bool is_js_array, | 1101 KeyedStoreElementStub(bool is_js_array, |
1041 ElementsKind elements_kind, | 1102 ElementsKind elements_kind, |
1042 KeyedAccessGrowMode grow_mode) | 1103 KeyedAccessGrowMode grow_mode) |
1043 : is_js_array_(is_js_array), | 1104 : is_js_array_(is_js_array), |
1044 elements_kind_(elements_kind), | 1105 elements_kind_(elements_kind), |
1045 grow_mode_(grow_mode), | 1106 grow_mode_(grow_mode), |
1046 fp_registers_(CanUseFPRegisters()) { } | 1107 fp_registers_(CanUseFPRegisters()) { } |
1047 | 1108 |
1048 Major MajorKey() { return KeyedStoreElement; } | 1109 Major MajorKey() { return KeyedStoreElement; } |
(...skipping 14 matching lines...) Expand all Loading... |
1063 | 1124 |
1064 bool is_js_array_; | 1125 bool is_js_array_; |
1065 ElementsKind elements_kind_; | 1126 ElementsKind elements_kind_; |
1066 KeyedAccessGrowMode grow_mode_; | 1127 KeyedAccessGrowMode grow_mode_; |
1067 bool fp_registers_; | 1128 bool fp_registers_; |
1068 | 1129 |
1069 DISALLOW_COPY_AND_ASSIGN(KeyedStoreElementStub); | 1130 DISALLOW_COPY_AND_ASSIGN(KeyedStoreElementStub); |
1070 }; | 1131 }; |
1071 | 1132 |
1072 | 1133 |
1073 class ToBooleanStub: public CodeStub { | 1134 class ToBooleanStub: public PlatformCodeStub { |
1074 public: | 1135 public: |
1075 enum Type { | 1136 enum Type { |
1076 UNDEFINED, | 1137 UNDEFINED, |
1077 BOOLEAN, | 1138 BOOLEAN, |
1078 NULL_TYPE, | 1139 NULL_TYPE, |
1079 SMI, | 1140 SMI, |
1080 SPEC_OBJECT, | 1141 SPEC_OBJECT, |
1081 STRING, | 1142 STRING, |
1082 HEAP_NUMBER, | 1143 HEAP_NUMBER, |
1083 NUMBER_OF_TYPES | 1144 NUMBER_OF_TYPES |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 Type type, | 1194 Type type, |
1134 Heap::RootListIndex value, | 1195 Heap::RootListIndex value, |
1135 bool result); | 1196 bool result); |
1136 void GenerateTypeTransition(MacroAssembler* masm); | 1197 void GenerateTypeTransition(MacroAssembler* masm); |
1137 | 1198 |
1138 Register tos_; | 1199 Register tos_; |
1139 Types types_; | 1200 Types types_; |
1140 }; | 1201 }; |
1141 | 1202 |
1142 | 1203 |
1143 class ElementsTransitionAndStoreStub : public CodeStub { | 1204 class ElementsTransitionAndStoreStub : public PlatformCodeStub { |
1144 public: | 1205 public: |
1145 ElementsTransitionAndStoreStub(ElementsKind from, | 1206 ElementsTransitionAndStoreStub(ElementsKind from, |
1146 ElementsKind to, | 1207 ElementsKind to, |
1147 bool is_jsarray, | 1208 bool is_jsarray, |
1148 StrictModeFlag strict_mode, | 1209 StrictModeFlag strict_mode, |
1149 KeyedAccessGrowMode grow_mode) | 1210 KeyedAccessGrowMode grow_mode) |
1150 : from_(from), | 1211 : from_(from), |
1151 to_(to), | 1212 to_(to), |
1152 is_jsarray_(is_jsarray), | 1213 is_jsarray_(is_jsarray), |
1153 strict_mode_(strict_mode), | 1214 strict_mode_(strict_mode), |
(...skipping 20 matching lines...) Expand all Loading... |
1174 ElementsKind from_; | 1235 ElementsKind from_; |
1175 ElementsKind to_; | 1236 ElementsKind to_; |
1176 bool is_jsarray_; | 1237 bool is_jsarray_; |
1177 StrictModeFlag strict_mode_; | 1238 StrictModeFlag strict_mode_; |
1178 KeyedAccessGrowMode grow_mode_; | 1239 KeyedAccessGrowMode grow_mode_; |
1179 | 1240 |
1180 DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); | 1241 DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); |
1181 }; | 1242 }; |
1182 | 1243 |
1183 | 1244 |
1184 class StoreArrayLiteralElementStub : public CodeStub { | 1245 class StoreArrayLiteralElementStub : public PlatformCodeStub { |
1185 public: | 1246 public: |
1186 StoreArrayLiteralElementStub() | 1247 StoreArrayLiteralElementStub() |
1187 : fp_registers_(CanUseFPRegisters()) { } | 1248 : fp_registers_(CanUseFPRegisters()) { } |
1188 | 1249 |
1189 private: | 1250 private: |
1190 class FPRegisters: public BitField<bool, 0, 1> {}; | 1251 class FPRegisters: public BitField<bool, 0, 1> {}; |
1191 | 1252 |
1192 Major MajorKey() { return StoreArrayLiteralElement; } | 1253 Major MajorKey() { return StoreArrayLiteralElement; } |
1193 int MinorKey() { return FPRegisters::encode(fp_registers_); } | 1254 int MinorKey() { return FPRegisters::encode(fp_registers_); } |
1194 | 1255 |
1195 void Generate(MacroAssembler* masm); | 1256 void Generate(MacroAssembler* masm); |
1196 | 1257 |
1197 bool fp_registers_; | 1258 bool fp_registers_; |
1198 | 1259 |
1199 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); | 1260 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); |
1200 }; | 1261 }; |
1201 | 1262 |
1202 | 1263 |
1203 class ProfileEntryHookStub : public CodeStub { | 1264 class ProfileEntryHookStub : public PlatformCodeStub { |
1204 public: | 1265 public: |
1205 explicit ProfileEntryHookStub() {} | 1266 explicit ProfileEntryHookStub() {} |
1206 | 1267 |
1207 // The profile entry hook function is not allowed to cause a GC. | 1268 // The profile entry hook function is not allowed to cause a GC. |
1208 virtual bool SometimesSetsUpAFrame() { return false; } | 1269 virtual bool SometimesSetsUpAFrame() { return false; } |
1209 | 1270 |
1210 // Generates a call to the entry hook if it's enabled. | 1271 // Generates a call to the entry hook if it's enabled. |
1211 static void MaybeCallEntryHook(MacroAssembler* masm); | 1272 static void MaybeCallEntryHook(MacroAssembler* masm); |
1212 | 1273 |
1213 // Sets or unsets the entry hook function. Returns true on success, | 1274 // Sets or unsets the entry hook function. Returns true on success, |
(...skipping 14 matching lines...) Expand all Loading... |
1228 | 1289 |
1229 // The current function entry hook. | 1290 // The current function entry hook. |
1230 static FunctionEntryHook entry_hook_; | 1291 static FunctionEntryHook entry_hook_; |
1231 | 1292 |
1232 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 1293 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
1233 }; | 1294 }; |
1234 | 1295 |
1235 } } // namespace v8::internal | 1296 } } // namespace v8::internal |
1236 | 1297 |
1237 #endif // V8_CODE_STUBS_H_ | 1298 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |