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