| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 35 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 36 | 36 |
| 37 #include "v8.h" | 37 #include "v8.h" |
| 38 | 38 |
| 39 #include "disassembler.h" | 39 #include "disassembler.h" |
| 40 #include "macro-assembler.h" | 40 #include "macro-assembler.h" |
| 41 #include "serialize.h" | 41 #include "serialize.h" |
| 42 | 42 |
| 43 namespace v8 { namespace internal { | 43 namespace v8 { namespace internal { |
| 44 | 44 |
| 45 DEFINE_bool(debug_code, false, | |
| 46 "generate extra code (comments, assertions) for debugging"); | |
| 47 DEFINE_bool(emit_branch_hints, false, "emit branch hints"); | |
| 48 | |
| 49 // ----------------------------------------------------------------------------- | 45 // ----------------------------------------------------------------------------- |
| 50 // Implementation of Register | 46 // Implementation of Register |
| 51 | 47 |
| 52 Register eax = { 0 }; | 48 Register eax = { 0 }; |
| 53 Register ecx = { 1 }; | 49 Register ecx = { 1 }; |
| 54 Register edx = { 2 }; | 50 Register edx = { 2 }; |
| 55 Register ebx = { 3 }; | 51 Register ebx = { 3 }; |
| 56 Register esp = { 4 }; | 52 Register esp = { 4 }; |
| 57 Register ebp = { 5 }; | 53 Register ebp = { 5 }; |
| 58 Register esi = { 6 }; | 54 Register esi = { 6 }; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (x.is_int8()) { | 401 if (x.is_int8()) { |
| 406 EMIT(0x6a); | 402 EMIT(0x6a); |
| 407 EMIT(x.x_); | 403 EMIT(x.x_); |
| 408 } else { | 404 } else { |
| 409 EMIT(0x68); | 405 EMIT(0x68); |
| 410 emit(x); | 406 emit(x); |
| 411 } | 407 } |
| 412 } | 408 } |
| 413 | 409 |
| 414 | 410 |
| 415 DEFINE_bool(push_pop_elimination, true, | |
| 416 "eliminate redundant push/pops in assembly code"); | |
| 417 DEFINE_bool(print_push_pop_elimination, false, | |
| 418 "print elimination of redundant push/pops in assembly code"); | |
| 419 | |
| 420 void Assembler::push(Register src) { | 411 void Assembler::push(Register src) { |
| 421 EnsureSpace ensure_space(this); | 412 EnsureSpace ensure_space(this); |
| 422 last_pc_ = pc_; | 413 last_pc_ = pc_; |
| 423 EMIT(0x50 | src.code()); | 414 EMIT(0x50 | src.code()); |
| 424 } | 415 } |
| 425 | 416 |
| 426 | 417 |
| 427 void Assembler::push(const Operand& src) { | 418 void Assembler::push(const Operand& src) { |
| 428 EnsureSpace ensure_space(this); | 419 EnsureSpace ensure_space(this); |
| 429 last_pc_ = pc_; | 420 last_pc_ = pc_; |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 disp.print(); | 1164 disp.print(); |
| 1174 PrintF("\n"); | 1165 PrintF("\n"); |
| 1175 disp.next(&l); | 1166 disp.next(&l); |
| 1176 } | 1167 } |
| 1177 } else { | 1168 } else { |
| 1178 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); | 1169 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); |
| 1179 } | 1170 } |
| 1180 } | 1171 } |
| 1181 | 1172 |
| 1182 | 1173 |
| 1183 DEFINE_bool(eliminate_jumps, true, "eliminate jumps to jumps in assembly code"); | |
| 1184 DEFINE_bool(print_jump_elimination, false, | |
| 1185 "print elimination of jumps to jumps in assembly code"); | |
| 1186 | |
| 1187 void Assembler::bind_to(Label* L, int pos) { | 1174 void Assembler::bind_to(Label* L, int pos) { |
| 1188 EnsureSpace ensure_space(this); | 1175 EnsureSpace ensure_space(this); |
| 1189 last_pc_ = NULL; | 1176 last_pc_ = NULL; |
| 1190 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position | 1177 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position |
| 1191 while (L->is_linked()) { | 1178 while (L->is_linked()) { |
| 1192 Displacement disp = disp_at(L); | 1179 Displacement disp = disp_at(L); |
| 1193 int fixup_pos = L->pos(); | 1180 int fixup_pos = L->pos(); |
| 1194 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { | 1181 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { |
| 1195 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected | 1182 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected |
| 1196 } | 1183 } |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 !Serializer::enabled() && | 2010 !Serializer::enabled() && |
| 2024 !FLAG_debug_code) { | 2011 !FLAG_debug_code) { |
| 2025 return; | 2012 return; |
| 2026 } | 2013 } |
| 2027 RelocInfo rinfo(pc_, rmode, data); | 2014 RelocInfo rinfo(pc_, rmode, data); |
| 2028 reloc_info_writer.Write(&rinfo); | 2015 reloc_info_writer.Write(&rinfo); |
| 2029 } | 2016 } |
| 2030 | 2017 |
| 2031 | 2018 |
| 2032 } } // namespace v8::internal | 2019 } } // namespace v8::internal |
| OLD | NEW |