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

Side by Side Diff: src/assembler.h

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « src/array.js ('k') | src/assembler.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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 17 matching lines...) Expand all
28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 // The original source code covered by the above license above has been 31 // The original source code covered by the above license above has been
32 // modified significantly by Google Inc. 32 // modified significantly by Google Inc.
33 // Copyright 2006-2009 the V8 project authors. All rights reserved. 33 // Copyright 2006-2009 the V8 project authors. All rights reserved.
34 34
35 #ifndef V8_ASSEMBLER_H_ 35 #ifndef V8_ASSEMBLER_H_
36 #define V8_ASSEMBLER_H_ 36 #define V8_ASSEMBLER_H_
37 37
38 #include "gdb-jit.h"
38 #include "runtime.h" 39 #include "runtime.h"
39 #include "top.h" 40 #include "top.h"
40 #include "token.h" 41 #include "token.h"
41 42
42 namespace v8 { 43 namespace v8 {
43 namespace internal { 44 namespace internal {
44 45
45 46
46 // ----------------------------------------------------------------------------- 47 // -----------------------------------------------------------------------------
47 // Common double constants. 48 // Common double constants.
48 49
49 class DoubleConstant: public AllStatic { 50 class DoubleConstant: public AllStatic {
50 public: 51 public:
51 static const double min_int; 52 static const double min_int;
52 static const double one_half; 53 static const double one_half;
54 static const double minus_zero;
53 static const double negative_infinity; 55 static const double negative_infinity;
54 }; 56 };
55 57
56 58
57 // ----------------------------------------------------------------------------- 59 // -----------------------------------------------------------------------------
58 // Labels represent pc locations; they are typically jump or call targets. 60 // Labels represent pc locations; they are typically jump or call targets.
59 // After declaration, a label can be freely used to denote known or (yet) 61 // After declaration, a label can be freely used to denote known or (yet)
60 // unknown pc location. Assembler::bind() is used to bind a label to the 62 // unknown pc location. Assembler::bind() is used to bind a label to the
61 // current pc. A label can be bound only once. 63 // current pc. A label can be bound only once.
62 64
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // in the relocation information. Two types of source positions are collected 174 // in the relocation information. Two types of source positions are collected
173 // "position" (RelocMode position) and "statement position" (RelocMode 175 // "position" (RelocMode position) and "statement position" (RelocMode
174 // statement_position). The "position" is collected at places in the source 176 // statement_position). The "position" is collected at places in the source
175 // code which are of interest when making stack traces to pin-point the source 177 // code which are of interest when making stack traces to pin-point the source
176 // location of a stack frame as close as possible. The "statement position" is 178 // location of a stack frame as close as possible. The "statement position" is
177 // collected at the beginning at each statement, and is used to indicate 179 // collected at the beginning at each statement, and is used to indicate
178 // possible break locations. kNoPosition is used to indicate an 180 // possible break locations. kNoPosition is used to indicate an
179 // invalid/uninitialized position value. 181 // invalid/uninitialized position value.
180 static const int kNoPosition = -1; 182 static const int kNoPosition = -1;
181 183
184 // This string is used to add padding comments to the reloc info in cases
185 // where we are not sure to have enough space for patching in during
186 // lazy deoptimization. This is the case if we have indirect calls for which
187 // we do not normally record relocation info.
188 static const char* kFillerCommentString;
189
182 enum Mode { 190 enum Mode {
183 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). 191 // Please note the order is important (see IsCodeTarget, IsGCRelocMode).
184 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. 192 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
185 CODE_TARGET_CONTEXT, // Code target used for contextual loads. 193 CODE_TARGET_CONTEXT, // Code target used for contextual loads and stores.
186 DEBUG_BREAK, // Code target for the debugger statement. 194 DEBUG_BREAK, // Code target for the debugger statement.
187 CODE_TARGET, // Code target which is not any of the above. 195 CODE_TARGET, // Code target which is not any of the above.
188 EMBEDDED_OBJECT, 196 EMBEDDED_OBJECT,
189
190 GLOBAL_PROPERTY_CELL, 197 GLOBAL_PROPERTY_CELL,
191 198
192 // Everything after runtime_entry (inclusive) is not GC'ed. 199 // Everything after runtime_entry (inclusive) is not GC'ed.
193 RUNTIME_ENTRY, 200 RUNTIME_ENTRY,
194 JS_RETURN, // Marks start of the ExitJSFrame code. 201 JS_RETURN, // Marks start of the ExitJSFrame code.
195 COMMENT, 202 COMMENT,
196 POSITION, // See comment for kNoPosition above. 203 POSITION, // See comment for kNoPosition above.
197 STATEMENT_POSITION, // See comment for kNoPosition above. 204 STATEMENT_POSITION, // See comment for kNoPosition above.
198 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. 205 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot.
199 EXTERNAL_REFERENCE, // The address of an external C++ function. 206 EXTERNAL_REFERENCE, // The address of an external C++ function.
200 INTERNAL_REFERENCE, // An address inside the same function. 207 INTERNAL_REFERENCE, // An address inside the same function.
201 208
202 // add more as needed 209 // add more as needed
203 // Pseudo-types 210 // Pseudo-types
204 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter 211 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter
205 NONE, // never recorded 212 NONE, // never recorded
206 LAST_CODE_ENUM = CODE_TARGET, 213 LAST_CODE_ENUM = CODE_TARGET,
207 LAST_GCED_ENUM = EMBEDDED_OBJECT 214 LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL
208 }; 215 };
209 216
210 217
211 RelocInfo() {} 218 RelocInfo() {}
212 RelocInfo(byte* pc, Mode rmode, intptr_t data) 219 RelocInfo(byte* pc, Mode rmode, intptr_t data)
213 : pc_(pc), rmode_(rmode), data_(data) { 220 : pc_(pc), rmode_(rmode), data_(data) {
214 } 221 }
215 222
216 static inline bool IsConstructCall(Mode mode) { 223 static inline bool IsConstructCall(Mode mode) {
217 return mode == CONSTRUCT_CALL; 224 return mode == CONSTRUCT_CALL;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // External function 461 // External function
455 462
456 //---------------------------------------------------------------------------- 463 //----------------------------------------------------------------------------
457 class IC_Utility; 464 class IC_Utility;
458 class SCTableReference; 465 class SCTableReference;
459 #ifdef ENABLE_DEBUGGER_SUPPORT 466 #ifdef ENABLE_DEBUGGER_SUPPORT
460 class Debug_Address; 467 class Debug_Address;
461 #endif 468 #endif
462 469
463 470
464 typedef void* ExternalReferenceRedirector(void* original, bool fp_return);
465
466
467 // An ExternalReference represents a C++ address used in the generated 471 // An ExternalReference represents a C++ address used in the generated
468 // code. All references to C++ functions and variables must be encapsulated in 472 // code. All references to C++ functions and variables must be encapsulated in
469 // an ExternalReference instance. This is done in order to track the origin of 473 // an ExternalReference instance. This is done in order to track the origin of
470 // all external references in the code so that they can be bound to the correct 474 // all external references in the code so that they can be bound to the correct
471 // addresses when deserializing a heap. 475 // addresses when deserializing a heap.
472 class ExternalReference BASE_EMBEDDED { 476 class ExternalReference BASE_EMBEDDED {
473 public: 477 public:
478 // Used in the simulator to support different native api calls.
479 //
480 // BUILTIN_CALL - builtin call.
481 // MaybeObject* f(v8::internal::Arguments).
482 //
483 // FP_RETURN_CALL - builtin call that returns floating point.
484 // double f(double, double).
485 //
486 // DIRECT_CALL - direct call to API function native callback
487 // from generated code.
488 // Handle<Value> f(v8::Arguments&)
489 //
490 enum Type {
491 BUILTIN_CALL, // default
492 FP_RETURN_CALL,
493 DIRECT_CALL
494 };
495
496 typedef void* ExternalReferenceRedirector(void* original, Type type);
497
474 explicit ExternalReference(Builtins::CFunctionId id); 498 explicit ExternalReference(Builtins::CFunctionId id);
475 499
476 explicit ExternalReference(ApiFunction* ptr); 500 explicit ExternalReference(ApiFunction* ptr, Type type);
477 501
478 explicit ExternalReference(Builtins::Name name); 502 explicit ExternalReference(Builtins::Name name);
479 503
480 explicit ExternalReference(Runtime::FunctionId id); 504 explicit ExternalReference(Runtime::FunctionId id);
481 505
482 explicit ExternalReference(Runtime::Function* f); 506 explicit ExternalReference(Runtime::Function* f);
483 507
484 explicit ExternalReference(const IC_Utility& ic_utility); 508 explicit ExternalReference(const IC_Utility& ic_utility);
485 509
486 #ifdef ENABLE_DEBUGGER_SUPPORT 510 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 21 matching lines...) Expand all
508 static ExternalReference compute_output_frames_function(); 532 static ExternalReference compute_output_frames_function();
509 static ExternalReference global_contexts_list(); 533 static ExternalReference global_contexts_list();
510 534
511 // Static data in the keyed lookup cache. 535 // Static data in the keyed lookup cache.
512 static ExternalReference keyed_lookup_cache_keys(); 536 static ExternalReference keyed_lookup_cache_keys();
513 static ExternalReference keyed_lookup_cache_field_offsets(); 537 static ExternalReference keyed_lookup_cache_field_offsets();
514 538
515 // Static variable Factory::the_hole_value.location() 539 // Static variable Factory::the_hole_value.location()
516 static ExternalReference the_hole_value_location(); 540 static ExternalReference the_hole_value_location();
517 541
542 // Static variable Factory::arguments_marker.location()
543 static ExternalReference arguments_marker_location();
544
518 // Static variable Heap::roots_address() 545 // Static variable Heap::roots_address()
519 static ExternalReference roots_address(); 546 static ExternalReference roots_address();
520 547
521 // Static variable StackGuard::address_of_jslimit() 548 // Static variable StackGuard::address_of_jslimit()
522 static ExternalReference address_of_stack_limit(); 549 static ExternalReference address_of_stack_limit();
523 550
524 // Static variable StackGuard::address_of_real_jslimit() 551 // Static variable StackGuard::address_of_real_jslimit()
525 static ExternalReference address_of_real_stack_limit(); 552 static ExternalReference address_of_real_stack_limit();
526 553
527 // Static variable RegExpStack::limit_address() 554 // Static variable RegExpStack::limit_address()
(...skipping 23 matching lines...) Expand all
551 578
552 static ExternalReference handle_scope_next_address(); 579 static ExternalReference handle_scope_next_address();
553 static ExternalReference handle_scope_limit_address(); 580 static ExternalReference handle_scope_limit_address();
554 static ExternalReference handle_scope_level_address(); 581 static ExternalReference handle_scope_level_address();
555 582
556 static ExternalReference scheduled_exception_address(); 583 static ExternalReference scheduled_exception_address();
557 584
558 // Static variables containing common double constants. 585 // Static variables containing common double constants.
559 static ExternalReference address_of_min_int(); 586 static ExternalReference address_of_min_int();
560 static ExternalReference address_of_one_half(); 587 static ExternalReference address_of_one_half();
588 static ExternalReference address_of_minus_zero();
561 static ExternalReference address_of_negative_infinity(); 589 static ExternalReference address_of_negative_infinity();
562 590
563 Address address() const {return reinterpret_cast<Address>(address_);} 591 Address address() const {return reinterpret_cast<Address>(address_);}
564 592
565 #ifdef ENABLE_DEBUGGER_SUPPORT 593 #ifdef ENABLE_DEBUGGER_SUPPORT
566 // Function Debug::Break() 594 // Function Debug::Break()
567 static ExternalReference debug_break(); 595 static ExternalReference debug_break();
568 596
569 // Used to check if single stepping is enabled in generated code. 597 // Used to check if single stepping is enabled in generated code.
570 static ExternalReference debug_step_in_fp_address(); 598 static ExternalReference debug_step_in_fp_address();
(...skipping 22 matching lines...) Expand all
593 ASSERT(redirector_ == NULL); // We can't stack them. 621 ASSERT(redirector_ == NULL); // We can't stack them.
594 redirector_ = redirector; 622 redirector_ = redirector;
595 } 623 }
596 624
597 private: 625 private:
598 explicit ExternalReference(void* address) 626 explicit ExternalReference(void* address)
599 : address_(address) {} 627 : address_(address) {}
600 628
601 static ExternalReferenceRedirector* redirector_; 629 static ExternalReferenceRedirector* redirector_;
602 630
603 static void* Redirect(void* address, bool fp_return = false) { 631 static void* Redirect(void* address,
632 Type type = ExternalReference::BUILTIN_CALL) {
604 if (redirector_ == NULL) return address; 633 if (redirector_ == NULL) return address;
605 void* answer = (*redirector_)(address, fp_return); 634 void* answer = (*redirector_)(address, type);
606 return answer; 635 return answer;
607 } 636 }
608 637
609 static void* Redirect(Address address_arg, bool fp_return = false) { 638 static void* Redirect(Address address_arg,
639 Type type = ExternalReference::BUILTIN_CALL) {
610 void* address = reinterpret_cast<void*>(address_arg); 640 void* address = reinterpret_cast<void*>(address_arg);
611 void* answer = (redirector_ == NULL) ? 641 void* answer = (redirector_ == NULL) ?
612 address : 642 address :
613 (*redirector_)(address, fp_return); 643 (*redirector_)(address, type);
614 return answer; 644 return answer;
615 } 645 }
616 646
617 void* address_; 647 void* address_;
618 }; 648 };
619 649
620 650
621 // ----------------------------------------------------------------------------- 651 // -----------------------------------------------------------------------------
622 // Position recording support 652 // Position recording support
623 653
624 struct PositionState { 654 struct PositionState {
625 PositionState() : current_position(RelocInfo::kNoPosition), 655 PositionState() : current_position(RelocInfo::kNoPosition),
626 written_position(RelocInfo::kNoPosition), 656 written_position(RelocInfo::kNoPosition),
627 current_statement_position(RelocInfo::kNoPosition), 657 current_statement_position(RelocInfo::kNoPosition),
628 written_statement_position(RelocInfo::kNoPosition) {} 658 written_statement_position(RelocInfo::kNoPosition) {}
629 659
630 int current_position; 660 int current_position;
631 int written_position; 661 int written_position;
632 662
633 int current_statement_position; 663 int current_statement_position;
634 int written_statement_position; 664 int written_statement_position;
635 }; 665 };
636 666
637 667
638 class PositionsRecorder BASE_EMBEDDED { 668 class PositionsRecorder BASE_EMBEDDED {
639 public: 669 public:
640 explicit PositionsRecorder(Assembler* assembler) 670 explicit PositionsRecorder(Assembler* assembler)
641 : assembler_(assembler) {} 671 : assembler_(assembler) {
672 #ifdef ENABLE_GDB_JIT_INTERFACE
673 gdbjit_lineinfo_ = NULL;
674 #endif
675 }
676
677 #ifdef ENABLE_GDB_JIT_INTERFACE
678 ~PositionsRecorder() {
679 delete gdbjit_lineinfo_;
680 }
681
682 void StartGDBJITLineInfoRecording() {
683 if (FLAG_gdbjit) {
684 gdbjit_lineinfo_ = new GDBJITLineInfo();
685 }
686 }
687
688 GDBJITLineInfo* DetachGDBJITLineInfo() {
689 GDBJITLineInfo* lineinfo = gdbjit_lineinfo_;
690 gdbjit_lineinfo_ = NULL; // To prevent deallocation in destructor.
691 return lineinfo;
692 }
693 #endif
642 694
643 // Set current position to pos. 695 // Set current position to pos.
644 void RecordPosition(int pos); 696 void RecordPosition(int pos);
645 697
646 // Set current statement position to pos. 698 // Set current statement position to pos.
647 void RecordStatementPosition(int pos); 699 void RecordStatementPosition(int pos);
648 700
649 // Write recorded positions to relocation information. 701 // Write recorded positions to relocation information.
650 bool WriteRecordedPositions(); 702 bool WriteRecordedPositions();
651 703
652 int current_position() const { return state_.current_position; } 704 int current_position() const { return state_.current_position; }
653 705
654 int current_statement_position() const { 706 int current_statement_position() const {
655 return state_.current_statement_position; 707 return state_.current_statement_position;
656 } 708 }
657 709
658 private: 710 private:
659 Assembler* assembler_; 711 Assembler* assembler_;
660 PositionState state_; 712 PositionState state_;
713 #ifdef ENABLE_GDB_JIT_INTERFACE
714 GDBJITLineInfo* gdbjit_lineinfo_;
715 #endif
661 716
662 friend class PreservePositionScope; 717 friend class PreservePositionScope;
663 718
664 DISALLOW_COPY_AND_ASSIGN(PositionsRecorder); 719 DISALLOW_COPY_AND_ASSIGN(PositionsRecorder);
665 }; 720 };
666 721
667 722
668 class PreservePositionScope BASE_EMBEDDED { 723 class PreservePositionScope BASE_EMBEDDED {
669 public: 724 public:
670 explicit PreservePositionScope(PositionsRecorder* positions_recorder) 725 explicit PreservePositionScope(PositionsRecorder* positions_recorder)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 return num_bits_set; 775 return num_bits_set;
721 } 776 }
722 777
723 // Computes pow(x, y) with the special cases in the spec for Math.pow. 778 // Computes pow(x, y) with the special cases in the spec for Math.pow.
724 double power_double_int(double x, int y); 779 double power_double_int(double x, int y);
725 double power_double_double(double x, double y); 780 double power_double_double(double x, double y);
726 781
727 } } // namespace v8::internal 782 } } // namespace v8::internal
728 783
729 #endif // V8_ASSEMBLER_H_ 784 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/array.js ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698