| OLD | NEW |
| 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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 Abort(msg); | 983 Abort(msg); |
| 984 // will not return here | 984 // will not return here |
| 985 bind(&L); | 985 bind(&L); |
| 986 } | 986 } |
| 987 | 987 |
| 988 | 988 |
| 989 void MacroAssembler::Abort(const char* msg) { | 989 void MacroAssembler::Abort(const char* msg) { |
| 990 // We want to pass the msg string like a smi to avoid GC | 990 // We want to pass the msg string like a smi to avoid GC |
| 991 // problems, however msg is not guaranteed to be aligned | 991 // problems, however msg is not guaranteed to be aligned |
| 992 // properly. Instead, we pass an aligned pointer that is | 992 // properly. Instead, we pass an aligned pointer that is |
| 993 // a proper v8 smi, but also pass the aligment difference | 993 // a proper v8 smi, but also pass the alignment difference |
| 994 // from the real pointer as a smi. | 994 // from the real pointer as a smi. |
| 995 intptr_t p1 = reinterpret_cast<intptr_t>(msg); | 995 intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
| 996 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; | 996 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
| 997 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); | 997 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
| 998 #ifdef DEBUG | 998 #ifdef DEBUG |
| 999 if (msg != NULL) { | 999 if (msg != NULL) { |
| 1000 RecordComment("Abort message: "); | 1000 RecordComment("Abort message: "); |
| 1001 RecordComment(msg); | 1001 RecordComment(msg); |
| 1002 } | 1002 } |
| 1003 #endif | 1003 #endif |
| 1004 push(eax); | 1004 push(eax); |
| 1005 push(Immediate(p0)); | 1005 push(Immediate(p0)); |
| 1006 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); | 1006 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); |
| 1007 CallRuntime(Runtime::kAbort, 2); | 1007 CallRuntime(Runtime::kAbort, 2); |
| 1008 // will not return here | 1008 // will not return here |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 | 1011 |
| 1012 CodePatcher::CodePatcher(byte* address, int size) | 1012 CodePatcher::CodePatcher(byte* address, int size) |
| 1013 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { | 1013 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { |
| 1014 // Create a new macro assembler pointing to the assress of the code to patch. | 1014 // Create a new macro assembler pointing to the address of the code to patch. |
| 1015 // The size is adjusted with kGap on order for the assembler to generate size | 1015 // The size is adjusted with kGap on order for the assembler to generate size |
| 1016 // bytes of instructions without failing with buffer size constraints. | 1016 // bytes of instructions without failing with buffer size constraints. |
| 1017 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1017 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 | 1020 |
| 1021 CodePatcher::~CodePatcher() { | 1021 CodePatcher::~CodePatcher() { |
| 1022 // Indicate that code has changed. | 1022 // Indicate that code has changed. |
| 1023 CPU::FlushICache(address_, size_); | 1023 CPU::FlushICache(address_, size_); |
| 1024 | 1024 |
| 1025 // Check that the code was patched as expected. | 1025 // Check that the code was patched as expected. |
| 1026 ASSERT(masm_.pc_ == address_ + size_); | 1026 ASSERT(masm_.pc_ == address_ + size_); |
| 1027 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1027 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 | 1030 |
| 1031 } } // namespace v8::internal | 1031 } } // namespace v8::internal |
| OLD | NEW |