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

Side by Side Diff: src/mips/assembler-mips.h

Issue 11416133: Moved buffer handling to AssemblerBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 1 month 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/ia32/assembler-ia32.cc ('k') | src/mips/assembler-mips.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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // 516 //
517 // If the provided buffer is NULL, the assembler allocates and grows its own 517 // If the provided buffer is NULL, the assembler allocates and grows its own
518 // buffer, and buffer_size determines the initial buffer size. The buffer is 518 // buffer, and buffer_size determines the initial buffer size. The buffer is
519 // owned by the assembler and deallocated upon destruction of the assembler. 519 // owned by the assembler and deallocated upon destruction of the assembler.
520 // 520 //
521 // If the provided buffer is not NULL, the assembler uses the provided buffer 521 // If the provided buffer is not NULL, the assembler uses the provided buffer
522 // for code generation and assumes its size to be buffer_size. If the buffer 522 // for code generation and assumes its size to be buffer_size. If the buffer
523 // is too small, a fatal error occurs. No deallocation of the buffer is done 523 // is too small, a fatal error occurs. No deallocation of the buffer is done
524 // upon destruction of the assembler. 524 // upon destruction of the assembler.
525 Assembler(Isolate* isolate, void* buffer, int buffer_size); 525 Assembler(Isolate* isolate, void* buffer, int buffer_size);
526 ~Assembler(); 526 virtual ~Assembler() { }
527 527
528 // GetCode emits any pending (non-emitted) code and fills the descriptor 528 // GetCode emits any pending (non-emitted) code and fills the descriptor
529 // desc. GetCode() is idempotent; it returns the same result if no other 529 // desc. GetCode() is idempotent; it returns the same result if no other
530 // Assembler functions are invoked in between GetCode() calls. 530 // Assembler functions are invoked in between GetCode() calls.
531 void GetCode(CodeDesc* desc); 531 void GetCode(CodeDesc* desc);
532 532
533 // Label operations & relative jumps (PPUM Appendix D). 533 // Label operations & relative jumps (PPUM Appendix D).
534 // 534 //
535 // Takes a branch opcode (cc) and a label (L) and generates 535 // Takes a branch opcode (cc) and a label (L) and generates
536 // either a backward branch or a forward branch and links it 536 // either a backward branch or a forward branch and links it
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 // Use --code-comments to enable. 936 // Use --code-comments to enable.
937 void RecordComment(const char* msg); 937 void RecordComment(const char* msg);
938 938
939 static int RelocateInternalReference(byte* pc, intptr_t pc_delta); 939 static int RelocateInternalReference(byte* pc, intptr_t pc_delta);
940 940
941 // Writes a single byte or word of data in the code stream. Used for 941 // Writes a single byte or word of data in the code stream. Used for
942 // inline tables, e.g., jump-tables. 942 // inline tables, e.g., jump-tables.
943 void db(uint8_t data); 943 void db(uint8_t data);
944 void dd(uint32_t data); 944 void dd(uint32_t data);
945 945
946 int32_t pc_offset() const { return pc_ - buffer_; }
947
948 PositionsRecorder* positions_recorder() { return &positions_recorder_; } 946 PositionsRecorder* positions_recorder() { return &positions_recorder_; }
949 947
950 // Postpone the generation of the trampoline pool for the specified number of 948 // Postpone the generation of the trampoline pool for the specified number of
951 // instructions. 949 // instructions.
952 void BlockTrampolinePoolFor(int instructions); 950 void BlockTrampolinePoolFor(int instructions);
953 951
954 // Check if there is less than kGap bytes available in the buffer. 952 // Check if there is less than kGap bytes available in the buffer.
955 // If this is the case, we need to grow the buffer before emitting 953 // If this is the case, we need to grow the buffer before emitting
956 // an instruction or relocation information. 954 // an instruction or relocation information.
957 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } 955 inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 void EndBlockGrowBuffer() { 1078 void EndBlockGrowBuffer() {
1081 ASSERT(block_buffer_growth_); 1079 ASSERT(block_buffer_growth_);
1082 block_buffer_growth_ = false; 1080 block_buffer_growth_ = false;
1083 } 1081 }
1084 1082
1085 bool is_buffer_growth_blocked() const { 1083 bool is_buffer_growth_blocked() const {
1086 return block_buffer_growth_; 1084 return block_buffer_growth_;
1087 } 1085 }
1088 1086
1089 private: 1087 private:
1090 // Code buffer:
1091 // The buffer into which code and relocation info are generated.
1092 byte* buffer_;
1093 int buffer_size_;
1094 // True if the assembler owns the buffer, false if buffer is external.
1095 bool own_buffer_;
1096
1097 // Buffer size and constant pool distance are checked together at regular 1088 // Buffer size and constant pool distance are checked together at regular
1098 // intervals of kBufferCheckInterval emitted bytes. 1089 // intervals of kBufferCheckInterval emitted bytes.
1099 static const int kBufferCheckInterval = 1*KB/2; 1090 static const int kBufferCheckInterval = 1*KB/2;
1100 1091
1101 // Code generation. 1092 // Code generation.
1102 // The relocation writer's position is at least kGap bytes below the end of 1093 // The relocation writer's position is at least kGap bytes below the end of
1103 // the generated instructions. This is so that multi-instruction sequences do 1094 // the generated instructions. This is so that multi-instruction sequences do
1104 // not have to check for overflow. The same is true for writes of large 1095 // not have to check for overflow. The same is true for writes of large
1105 // relocation info entries. 1096 // relocation info entries.
1106 static const int kGap = 32; 1097 static const int kGap = 32;
1107 byte* pc_; // The program counter - moves forward.
1108 1098
1109 1099
1110 // Repeated checking whether the trampoline pool should be emitted is rather 1100 // Repeated checking whether the trampoline pool should be emitted is rather
1111 // expensive. By default we only check again once a number of instructions 1101 // expensive. By default we only check again once a number of instructions
1112 // has been generated. 1102 // has been generated.
1113 static const int kCheckConstIntervalInst = 32; 1103 static const int kCheckConstIntervalInst = 32;
1114 static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize; 1104 static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize;
1115 1105
1116 int next_buffer_check_; // pc offset of next buffer check. 1106 int next_buffer_check_; // pc offset of next buffer check.
1117 1107
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 class EnsureSpace BASE_EMBEDDED { 1277 class EnsureSpace BASE_EMBEDDED {
1288 public: 1278 public:
1289 explicit EnsureSpace(Assembler* assembler) { 1279 explicit EnsureSpace(Assembler* assembler) {
1290 assembler->CheckBuffer(); 1280 assembler->CheckBuffer();
1291 } 1281 }
1292 }; 1282 };
1293 1283
1294 } } // namespace v8::internal 1284 } } // namespace v8::internal
1295 1285
1296 #endif // V8_ARM_ASSEMBLER_MIPS_H_ 1286 #endif // V8_ARM_ASSEMBLER_MIPS_H_
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/mips/assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698