Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: src/code-stubs.h

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/checks.h ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_CODE_STUBS_H_ 28 #ifndef V8_CODE_STUBS_H_
29 #define V8_CODE_STUBS_H_ 29 #define V8_CODE_STUBS_H_
30 30
31 #include "globals.h" 31 #include "globals.h"
32 #include "macro-assembler.h"
33 32
34 namespace v8 { 33 namespace v8 {
35 namespace internal { 34 namespace internal {
36 35
37 // List of code stubs used on all platforms. The order in this list is important 36 // List of code stubs used on all platforms. The order in this list is important
38 // as only the stubs up to and including RecordWrite allows nested stub calls. 37 // as only the stubs up to and including RecordWrite allows nested stub calls.
39 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ 38 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \
40 V(CallFunction) \ 39 V(CallFunction) \
41 V(GenericBinaryOp) \ 40 V(GenericBinaryOp) \
41 V(TypeRecordingBinaryOp) \
42 V(StringAdd) \ 42 V(StringAdd) \
43 V(StringCharAt) \
43 V(SubString) \ 44 V(SubString) \
44 V(StringCompare) \ 45 V(StringCompare) \
45 V(SmiOp) \ 46 V(SmiOp) \
46 V(Compare) \ 47 V(Compare) \
48 V(CompareIC) \
49 V(MathPow) \
47 V(RecordWrite) \ 50 V(RecordWrite) \
48 V(ConvertToDouble) \ 51 V(ConvertToDouble) \
49 V(WriteInt32ToHeapNumber) \ 52 V(WriteInt32ToHeapNumber) \
50 V(IntegerMod) \ 53 V(IntegerMod) \
51 V(StackCheck) \ 54 V(StackCheck) \
52 V(FastNewClosure) \ 55 V(FastNewClosure) \
53 V(FastNewContext) \ 56 V(FastNewContext) \
54 V(FastCloneShallowArray) \ 57 V(FastCloneShallowArray) \
55 V(TranscendentalCache) \ 58 V(TranscendentalCache) \
56 V(GenericUnaryOp) \ 59 V(GenericUnaryOp) \
57 V(RevertToNumber) \ 60 V(RevertToNumber) \
58 V(ToBoolean) \ 61 V(ToBoolean) \
59 V(Instanceof) \ 62 V(Instanceof) \
60 V(CounterOp) \ 63 V(CounterOp) \
61 V(ArgumentsAccess) \ 64 V(ArgumentsAccess) \
62 V(RegExpExec) \ 65 V(RegExpExec) \
66 V(RegExpConstructResult) \
63 V(NumberToString) \ 67 V(NumberToString) \
64 V(CEntry) \ 68 V(CEntry) \
65 V(JSEntry) \ 69 V(JSEntry) \
66 V(DebuggerStatement) 70 V(DebuggerStatement)
67 71
68 // List of code stubs only used on ARM platforms. 72 // List of code stubs only used on ARM platforms.
69 #ifdef V8_TARGET_ARCH_ARM 73 #ifdef V8_TARGET_ARCH_ARM
70 #define CODE_STUB_LIST_ARM(V) \ 74 #define CODE_STUB_LIST_ARM(V) \
71 V(GetProperty) \ 75 V(GetProperty) \
72 V(SetProperty) \ 76 V(SetProperty) \
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Gets the major key from a code object that is a code stub or binary op IC. 122 // Gets the major key from a code object that is a code stub or binary op IC.
119 static Major GetMajorKey(Code* code_stub) { 123 static Major GetMajorKey(Code* code_stub) {
120 return static_cast<Major>(code_stub->major_key()); 124 return static_cast<Major>(code_stub->major_key());
121 } 125 }
122 126
123 static const char* MajorName(Major major_key, bool allow_unknown_keys); 127 static const char* MajorName(Major major_key, bool allow_unknown_keys);
124 128
125 virtual ~CodeStub() {} 129 virtual ~CodeStub() {}
126 130
127 protected: 131 protected:
128 static const int kMajorBits = 5; 132 static const int kMajorBits = 6;
129 static const int kMinorBits = kBitsPerInt - kSmiTagSize - kMajorBits; 133 static const int kMinorBits = kBitsPerInt - kSmiTagSize - kMajorBits;
130 134
131 private: 135 private:
132 // Lookup the code in the (possibly custom) cache. 136 // Lookup the code in the (possibly custom) cache.
133 bool FindCodeInCache(Code** code_out); 137 bool FindCodeInCache(Code** code_out);
134 138
135 // Nonvirtual wrapper around the stub-specific Generate function. Call 139 // Nonvirtual wrapper around the stub-specific Generate function. Call
136 // this function to set up the macro assembler and generate the code. 140 // this function to set up the macro assembler and generate the code.
137 void GenerateCode(MacroAssembler* masm); 141 void GenerateCode(MacroAssembler* masm);
138 142
139 // Generates the assembler code for the stub. 143 // Generates the assembler code for the stub.
140 virtual void Generate(MacroAssembler* masm) = 0; 144 virtual void Generate(MacroAssembler* masm) = 0;
141 145
142 // Perform bookkeeping required after code generation when stub code is 146 // Perform bookkeeping required after code generation when stub code is
143 // initially generated. 147 // initially generated.
144 void RecordCodeGeneration(Code* code, MacroAssembler* masm); 148 void RecordCodeGeneration(Code* code, MacroAssembler* masm);
145 149
150 // Finish the code object after it has been generated.
151 virtual void FinishCode(Code* code) { }
152
146 // Returns information for computing the number key. 153 // Returns information for computing the number key.
147 virtual Major MajorKey() = 0; 154 virtual Major MajorKey() = 0;
148 virtual int MinorKey() = 0; 155 virtual int MinorKey() = 0;
149 156
150 // The CallFunctionStub needs to override this so it can encode whether a 157 // The CallFunctionStub needs to override this so it can encode whether a
151 // lazily generated function should be fully optimized or not. 158 // lazily generated function should be fully optimized or not.
152 virtual InLoopFlag InLoop() { return NOT_IN_LOOP; } 159 virtual InLoopFlag InLoop() { return NOT_IN_LOOP; }
153 160
154 // GenericBinaryOpStub needs to override this. 161 // GenericBinaryOpStub needs to override this.
155 virtual int GetCodeKind(); 162 virtual int GetCodeKind();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 #elif V8_TARGET_ARCH_MIPS 216 #elif V8_TARGET_ARCH_MIPS
210 #include "mips/code-stubs-mips.h" 217 #include "mips/code-stubs-mips.h"
211 #else 218 #else
212 #error Unsupported target architecture. 219 #error Unsupported target architecture.
213 #endif 220 #endif
214 221
215 namespace v8 { 222 namespace v8 {
216 namespace internal { 223 namespace internal {
217 224
218 225
219 // RuntimeCallHelper implementation used in IC stubs: enters/leaves a 226 // RuntimeCallHelper implementation used in stubs: enters/leaves a
220 // newly created internal frame before/after the runtime call. 227 // newly created internal frame before/after the runtime call.
221 class ICRuntimeCallHelper : public RuntimeCallHelper { 228 class StubRuntimeCallHelper : public RuntimeCallHelper {
222 public: 229 public:
223 ICRuntimeCallHelper() {} 230 StubRuntimeCallHelper() {}
224 231
225 virtual void BeforeCall(MacroAssembler* masm) const; 232 virtual void BeforeCall(MacroAssembler* masm) const;
226 233
227 virtual void AfterCall(MacroAssembler* masm) const; 234 virtual void AfterCall(MacroAssembler* masm) const;
228 }; 235 };
229 236
230 237
231 // Trivial RuntimeCallHelper implementation. 238 // Trivial RuntimeCallHelper implementation.
232 class NopRuntimeCallHelper : public RuntimeCallHelper { 239 class NopRuntimeCallHelper : public RuntimeCallHelper {
233 public: 240 public:
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 IncludeSmiCodeField::encode(include_smi_code_) | 376 IncludeSmiCodeField::encode(include_smi_code_) |
370 NegativeZeroField::encode(negative_zero_); 377 NegativeZeroField::encode(negative_zero_);
371 } 378 }
372 379
373 void Generate(MacroAssembler* masm); 380 void Generate(MacroAssembler* masm);
374 381
375 const char* GetName(); 382 const char* GetName();
376 }; 383 };
377 384
378 385
379 enum NaNInformation { 386 class MathPowStub: public CodeStub {
380 kBothCouldBeNaN, 387 public:
381 kCantBothBeNaN 388 MathPowStub() {}
389 virtual void Generate(MacroAssembler* masm);
390
391 private:
392 virtual CodeStub::Major MajorKey() { return MathPow; }
393 virtual int MinorKey() { return 0; }
394
395 const char* GetName() { return "MathPowStub"; }
382 }; 396 };
383 397
384 398
399 class StringCharAtStub: public CodeStub {
400 public:
401 StringCharAtStub() {}
402
403 private:
404 Major MajorKey() { return StringCharAt; }
405 int MinorKey() { return 0; }
406
407 void Generate(MacroAssembler* masm);
408 };
409
410
411 class ICCompareStub: public CodeStub {
412 public:
413 ICCompareStub(Token::Value op, CompareIC::State state)
414 : op_(op), state_(state) {
415 ASSERT(Token::IsCompareOp(op));
416 }
417
418 virtual void Generate(MacroAssembler* masm);
419
420 private:
421 class OpField: public BitField<int, 0, 3> { };
422 class StateField: public BitField<int, 3, 5> { };
423
424 virtual void FinishCode(Code* code) { code->set_compare_state(state_); }
425
426 virtual CodeStub::Major MajorKey() { return CompareIC; }
427 virtual int MinorKey();
428
429 virtual int GetCodeKind() { return Code::COMPARE_IC; }
430
431 void GenerateSmis(MacroAssembler* masm);
432 void GenerateHeapNumbers(MacroAssembler* masm);
433 void GenerateObjects(MacroAssembler* masm);
434 void GenerateMiss(MacroAssembler* masm);
435
436 bool strict() const { return op_ == Token::EQ_STRICT; }
437 Condition GetCondition() const { return CompareIC::ComputeCondition(op_); }
438
439 Token::Value op_;
440 CompareIC::State state_;
441 };
442
443
385 // Flags that control the compare stub code generation. 444 // Flags that control the compare stub code generation.
386 enum CompareFlags { 445 enum CompareFlags {
387 NO_COMPARE_FLAGS = 0, 446 NO_COMPARE_FLAGS = 0,
388 NO_SMI_COMPARE_IN_STUB = 1 << 0, 447 NO_SMI_COMPARE_IN_STUB = 1 << 0,
389 NO_NUMBER_COMPARE_IN_STUB = 1 << 1, 448 NO_NUMBER_COMPARE_IN_STUB = 1 << 1,
390 CANT_BOTH_BE_NAN = 1 << 2 449 CANT_BOTH_BE_NAN = 1 << 2
391 }; 450 };
392 451
393 452
453 enum NaNInformation {
454 kBothCouldBeNaN,
455 kCantBothBeNaN
456 };
457
458
394 class CompareStub: public CodeStub { 459 class CompareStub: public CodeStub {
395 public: 460 public:
396 CompareStub(Condition cc, 461 CompareStub(Condition cc,
397 bool strict, 462 bool strict,
398 CompareFlags flags, 463 CompareFlags flags,
399 Register lhs, 464 Register lhs,
400 Register rhs) : 465 Register rhs) :
401 cc_(cc), 466 cc_(cc),
402 strict_(strict), 467 strict_(strict),
403 never_nan_nan_((flags & CANT_BOTH_BE_NAN) != 0), 468 never_nan_nan_((flags & CANT_BOTH_BE_NAN) != 0),
404 include_number_compare_((flags & NO_NUMBER_COMPARE_IN_STUB) == 0), 469 include_number_compare_((flags & NO_NUMBER_COMPARE_IN_STUB) == 0),
405 include_smi_compare_((flags & NO_SMI_COMPARE_IN_STUB) == 0), 470 include_smi_compare_((flags & NO_SMI_COMPARE_IN_STUB) == 0),
406 lhs_(lhs), 471 lhs_(lhs),
407 rhs_(rhs), 472 rhs_(rhs),
408 name_(NULL) { } 473 name_(NULL) { }
409 474
410 CompareStub(Condition cc, 475 CompareStub(Condition cc,
411 bool strict, 476 bool strict,
(...skipping 21 matching lines...) Expand all
433 // Do generate the number comparison code in the stub. Stubs without number 498 // Do generate the number comparison code in the stub. Stubs without number
434 // comparison code is used when the number comparison has been inlined, and 499 // comparison code is used when the number comparison has been inlined, and
435 // the stub will be called if one of the operands is not a number. 500 // the stub will be called if one of the operands is not a number.
436 bool include_number_compare_; 501 bool include_number_compare_;
437 502
438 // Generate the comparison code for two smi operands in the stub. 503 // Generate the comparison code for two smi operands in the stub.
439 bool include_smi_compare_; 504 bool include_smi_compare_;
440 505
441 // Register holding the left hand side of the comparison if the stub gives 506 // Register holding the left hand side of the comparison if the stub gives
442 // a choice, no_reg otherwise. 507 // a choice, no_reg otherwise.
508
443 Register lhs_; 509 Register lhs_;
444 // Register holding the right hand side of the comparison if the stub gives 510 // Register holding the right hand side of the comparison if the stub gives
445 // a choice, no_reg otherwise. 511 // a choice, no_reg otherwise.
446 Register rhs_; 512 Register rhs_;
447 513
448 // Encoding of the minor key in 16 bits. 514 // Encoding of the minor key in 16 bits.
449 class StrictField: public BitField<bool, 0, 1> {}; 515 class StrictField: public BitField<bool, 0, 1> {};
450 class NeverNanNanField: public BitField<bool, 1, 1> {}; 516 class NeverNanNanField: public BitField<bool, 1, 1> {};
451 class IncludeNumberCompareField: public BitField<bool, 2, 1> {}; 517 class IncludeNumberCompareField: public BitField<bool, 2, 1> {};
452 class IncludeSmiCompareField: public BitField<bool, 3, 1> {}; 518 class IncludeSmiCompareField: public BitField<bool, 3, 1> {};
453 class RegisterField: public BitField<bool, 4, 1> {}; 519 class RegisterField: public BitField<bool, 4, 1> {};
454 class ConditionField: public BitField<int, 5, 11> {}; 520 class ConditionField: public BitField<int, 5, 11> {};
455 521
456 Major MajorKey() { return Compare; } 522 Major MajorKey() { return Compare; }
457 523
458 int MinorKey(); 524 int MinorKey();
459 525
526 virtual int GetCodeKind() { return Code::COMPARE_IC; }
527 virtual void FinishCode(Code* code) {
528 code->set_compare_state(CompareIC::GENERIC);
529 }
530
460 // Branch to the label if the given object isn't a symbol. 531 // Branch to the label if the given object isn't a symbol.
461 void BranchIfNonSymbol(MacroAssembler* masm, 532 void BranchIfNonSymbol(MacroAssembler* masm,
462 Label* label, 533 Label* label,
463 Register object, 534 Register object,
464 Register scratch); 535 Register scratch);
465 536
466 // Unfortunately you have to run without snapshots to see most of these 537 // Unfortunately you have to run without snapshots to see most of these
467 // names in the profile since most compare stubs end up in the snapshot. 538 // names in the profile since most compare stubs end up in the snapshot.
468 char* name_; 539 char* name_;
469 const char* GetName(); 540 const char* GetName();
(...skipping 13 matching lines...) Expand all
483 } else { 554 } else {
484 PrintF("\n"); 555 PrintF("\n");
485 } 556 }
486 } 557 }
487 #endif 558 #endif
488 }; 559 };
489 560
490 561
491 class CEntryStub : public CodeStub { 562 class CEntryStub : public CodeStub {
492 public: 563 public:
493 explicit CEntryStub(int result_size) : result_size_(result_size) { } 564 explicit CEntryStub(int result_size)
565 : result_size_(result_size), save_doubles_(false) { }
494 566
495 void Generate(MacroAssembler* masm); 567 void Generate(MacroAssembler* masm);
568 void SaveDoubles() { save_doubles_ = true; }
496 569
497 private: 570 private:
498 void GenerateCore(MacroAssembler* masm, 571 void GenerateCore(MacroAssembler* masm,
499 Label* throw_normal_exception, 572 Label* throw_normal_exception,
500 Label* throw_termination_exception, 573 Label* throw_termination_exception,
501 Label* throw_out_of_memory_exception, 574 Label* throw_out_of_memory_exception,
502 bool do_gc, 575 bool do_gc,
503 bool always_allocate_scope, 576 bool always_allocate_scope,
504 int alignment_skew = 0); 577 int alignment_skew = 0);
505 void GenerateThrowTOS(MacroAssembler* masm); 578 void GenerateThrowTOS(MacroAssembler* masm);
506 void GenerateThrowUncatchable(MacroAssembler* masm, 579 void GenerateThrowUncatchable(MacroAssembler* masm,
507 UncatchableExceptionType type); 580 UncatchableExceptionType type);
508 581
509 // Number of pointers/values returned. 582 // Number of pointers/values returned.
510 const int result_size_; 583 const int result_size_;
584 bool save_doubles_;
511 585
512 Major MajorKey() { return CEntry; } 586 Major MajorKey() { return CEntry; }
513 // Minor key must differ if different result_size_ values means different
514 // code is generated.
515 int MinorKey(); 587 int MinorKey();
516 588
517 const char* GetName() { return "CEntryStub"; } 589 const char* GetName() { return "CEntryStub"; }
518 }; 590 };
519 591
520 592
521 class JSEntryStub : public CodeStub { 593 class JSEntryStub : public CodeStub {
522 public: 594 public:
523 JSEntryStub() { } 595 JSEntryStub() { }
524 596
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 const char* GetName() { return "RegExpExecStub"; } 662 const char* GetName() { return "RegExpExecStub"; }
591 663
592 #ifdef DEBUG 664 #ifdef DEBUG
593 void Print() { 665 void Print() {
594 PrintF("RegExpExecStub\n"); 666 PrintF("RegExpExecStub\n");
595 } 667 }
596 #endif 668 #endif
597 }; 669 };
598 670
599 671
672 class RegExpConstructResultStub: public CodeStub {
673 public:
674 RegExpConstructResultStub() { }
675
676 private:
677 Major MajorKey() { return RegExpConstructResult; }
678 int MinorKey() { return 0; }
679
680 void Generate(MacroAssembler* masm);
681
682 const char* GetName() { return "RegExpConstructResultStub"; }
683
684 #ifdef DEBUG
685 void Print() {
686 PrintF("RegExpConstructResultStub\n");
687 }
688 #endif
689 };
690
691
600 class CallFunctionStub: public CodeStub { 692 class CallFunctionStub: public CodeStub {
601 public: 693 public:
602 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) 694 CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags)
603 : argc_(argc), in_loop_(in_loop), flags_(flags) { } 695 : argc_(argc), in_loop_(in_loop), flags_(flags) { }
604 696
605 void Generate(MacroAssembler* masm); 697 void Generate(MacroAssembler* masm);
606 698
607 private: 699 private:
608 int argc_; 700 int argc_;
609 InLoopFlag in_loop_; 701 InLoopFlag in_loop_;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 private: 887 private:
796 StringCharCodeAtGenerator char_code_at_generator_; 888 StringCharCodeAtGenerator char_code_at_generator_;
797 StringCharFromCodeGenerator char_from_code_generator_; 889 StringCharFromCodeGenerator char_from_code_generator_;
798 890
799 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); 891 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator);
800 }; 892 };
801 893
802 } } // namespace v8::internal 894 } } // namespace v8::internal
803 895
804 #endif // V8_CODE_STUBS_H_ 896 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/checks.h ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698