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

Side by Side Diff: src/arm/assembler-arm.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 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 | « no previous file | src/arm/assembler-arm.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 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // 640 //
641 // If the provided buffer is NULL, the assembler allocates and grows its own 641 // If the provided buffer is NULL, the assembler allocates and grows its own
642 // buffer, and buffer_size determines the initial buffer size. The buffer is 642 // buffer, and buffer_size determines the initial buffer size. The buffer is
643 // owned by the assembler and deallocated upon destruction of the assembler. 643 // owned by the assembler and deallocated upon destruction of the assembler.
644 // 644 //
645 // If the provided buffer is not NULL, the assembler uses the provided buffer 645 // If the provided buffer is not NULL, the assembler uses the provided buffer
646 // for code generation and assumes its size to be buffer_size. If the buffer 646 // for code generation and assumes its size to be buffer_size. If the buffer
647 // is too small, a fatal error occurs. No deallocation of the buffer is done 647 // is too small, a fatal error occurs. No deallocation of the buffer is done
648 // upon destruction of the assembler. 648 // upon destruction of the assembler.
649 Assembler(Isolate* isolate, void* buffer, int buffer_size); 649 Assembler(Isolate* isolate, void* buffer, int buffer_size);
650 ~Assembler(); 650 virtual ~Assembler();
651 651
652 // GetCode emits any pending (non-emitted) code and fills the descriptor 652 // GetCode emits any pending (non-emitted) code and fills the descriptor
653 // desc. GetCode() is idempotent; it returns the same result if no other 653 // desc. GetCode() is idempotent; it returns the same result if no other
654 // Assembler functions are invoked in between GetCode() calls. 654 // Assembler functions are invoked in between GetCode() calls.
655 void GetCode(CodeDesc* desc); 655 void GetCode(CodeDesc* desc);
656 656
657 // Label operations & relative jumps (PPUM Appendix D) 657 // Label operations & relative jumps (PPUM Appendix D)
658 // 658 //
659 // Takes a branch opcode (cc) and a label (L) and generates 659 // Takes a branch opcode (cc) and a label (L) and generates
660 // either a backward branch or a forward branch and links it 660 // either a backward branch or a forward branch and links it
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 // the marker and branch over the data. 1269 // the marker and branch over the data.
1270 void RecordConstPool(int size); 1270 void RecordConstPool(int size);
1271 1271
1272 // Writes a single byte or word of data in the code stream. Used 1272 // Writes a single byte or word of data in the code stream. Used
1273 // for inline tables, e.g., jump-tables. The constant pool should be 1273 // for inline tables, e.g., jump-tables. The constant pool should be
1274 // emitted before any use of db and dd to ensure that constant pools 1274 // emitted before any use of db and dd to ensure that constant pools
1275 // are not emitted as part of the tables generated. 1275 // are not emitted as part of the tables generated.
1276 void db(uint8_t data); 1276 void db(uint8_t data);
1277 void dd(uint32_t data); 1277 void dd(uint32_t data);
1278 1278
1279 int pc_offset() const { return pc_ - buffer_; }
1280
1281 PositionsRecorder* positions_recorder() { return &positions_recorder_; } 1279 PositionsRecorder* positions_recorder() { return &positions_recorder_; }
1282 1280
1283 // Read/patch instructions 1281 // Read/patch instructions
1284 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } 1282 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); }
1285 void instr_at_put(int pos, Instr instr) { 1283 void instr_at_put(int pos, Instr instr) {
1286 *reinterpret_cast<Instr*>(buffer_ + pos) = instr; 1284 *reinterpret_cast<Instr*>(buffer_ + pos) = instr;
1287 } 1285 }
1288 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } 1286 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); }
1289 static void instr_at_put(byte* pc, Instr instr) { 1287 static void instr_at_put(byte* pc, Instr instr) {
1290 *reinterpret_cast<Instr*>(pc) = instr; 1288 *reinterpret_cast<Instr*>(pc) = instr;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 next_buffer_check_ = no_const_pool_before_; 1371 next_buffer_check_ = no_const_pool_before_;
1374 } 1372 }
1375 } 1373 }
1376 1374
1377 bool is_const_pool_blocked() const { 1375 bool is_const_pool_blocked() const {
1378 return (const_pool_blocked_nesting_ > 0) || 1376 return (const_pool_blocked_nesting_ > 0) ||
1379 (pc_offset() < no_const_pool_before_); 1377 (pc_offset() < no_const_pool_before_);
1380 } 1378 }
1381 1379
1382 private: 1380 private:
1383 // Code buffer:
1384 // The buffer into which code and relocation info are generated.
1385 byte* buffer_;
1386 int buffer_size_;
1387 // True if the assembler owns the buffer, false if buffer is external.
1388 bool own_buffer_;
1389
1390 int next_buffer_check_; // pc offset of next buffer check 1381 int next_buffer_check_; // pc offset of next buffer check
1391 1382
1392 // Code generation 1383 // Code generation
1393 // The relocation writer's position is at least kGap bytes below the end of 1384 // The relocation writer's position is at least kGap bytes below the end of
1394 // the generated instructions. This is so that multi-instruction sequences do 1385 // the generated instructions. This is so that multi-instruction sequences do
1395 // not have to check for overflow. The same is true for writes of large 1386 // not have to check for overflow. The same is true for writes of large
1396 // relocation info entries. 1387 // relocation info entries.
1397 static const int kGap = 32; 1388 static const int kGap = 32;
1398 byte* pc_; // the program counter; moves forward
1399 1389
1400 // Constant pool generation 1390 // Constant pool generation
1401 // Pools are emitted in the instruction stream, preferably after unconditional 1391 // Pools are emitted in the instruction stream, preferably after unconditional
1402 // jumps or after returns from functions (in dead code locations). 1392 // jumps or after returns from functions (in dead code locations).
1403 // If a long code sequence does not contain unconditional jumps, it is 1393 // If a long code sequence does not contain unconditional jumps, it is
1404 // necessary to emit the constant pool before the pool gets too far from the 1394 // necessary to emit the constant pool before the pool gets too far from the
1405 // location it is accessed from. In this case, we emit a jump over the emitted 1395 // location it is accessed from. In this case, we emit a jump over the emitted
1406 // constant pool. 1396 // constant pool.
1407 // Constants in the pool may be addresses of functions that gets relocated; 1397 // Constants in the pool may be addresses of functions that gets relocated;
1408 // if so, a relocation info entry is associated to the constant pool entry. 1398 // if so, a relocation info entry is associated to the constant pool entry.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 public: 1488 public:
1499 explicit EnsureSpace(Assembler* assembler) { 1489 explicit EnsureSpace(Assembler* assembler) {
1500 assembler->CheckBuffer(); 1490 assembler->CheckBuffer();
1501 } 1491 }
1502 }; 1492 };
1503 1493
1504 1494
1505 } } // namespace v8::internal 1495 } } // namespace v8::internal
1506 1496
1507 #endif // V8_ARM_ASSEMBLER_ARM_H_ 1497 #endif // V8_ARM_ASSEMBLER_ARM_H_
OLDNEW
« no previous file with comments | « no previous file | src/arm/assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698