OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 }; | 1422 }; |
1423 | 1423 |
1424 | 1424 |
1425 // The code patcher is used to patch (typically) small parts of code e.g. for | 1425 // The code patcher is used to patch (typically) small parts of code e.g. for |
1426 // debugging and other types of instrumentation. When using the code patcher | 1426 // debugging and other types of instrumentation. When using the code patcher |
1427 // the exact number of bytes specified must be emitted. It is not legal to emit | 1427 // the exact number of bytes specified must be emitted. It is not legal to emit |
1428 // relocation information. If any of these constraints are violated it causes | 1428 // relocation information. If any of these constraints are violated it causes |
1429 // an assertion to fail. | 1429 // an assertion to fail. |
1430 class CodePatcher { | 1430 class CodePatcher { |
1431 public: | 1431 public: |
1432 CodePatcher(byte* address, int instructions); | 1432 enum FlushICache { |
| 1433 FLUSH, |
| 1434 DONT_FLUSH |
| 1435 }; |
| 1436 |
| 1437 CodePatcher(byte* address, |
| 1438 int instructions, |
| 1439 FlushICache flush_cache = FLUSH); |
1433 virtual ~CodePatcher(); | 1440 virtual ~CodePatcher(); |
1434 | 1441 |
1435 // Macro assembler to emit code. | 1442 // Macro assembler to emit code. |
1436 MacroAssembler* masm() { return &masm_; } | 1443 MacroAssembler* masm() { return &masm_; } |
1437 | 1444 |
1438 // Emit an instruction directly. | 1445 // Emit an instruction directly. |
1439 void Emit(Instr instr); | 1446 void Emit(Instr instr); |
1440 | 1447 |
1441 // Emit an address directly. | 1448 // Emit an address directly. |
1442 void Emit(Address addr); | 1449 void Emit(Address addr); |
1443 | 1450 |
1444 // Emit the condition part of an instruction leaving the rest of the current | 1451 // Emit the condition part of an instruction leaving the rest of the current |
1445 // instruction unchanged. | 1452 // instruction unchanged. |
1446 void EmitCondition(Condition cond); | 1453 void EmitCondition(Condition cond); |
1447 | 1454 |
1448 private: | 1455 private: |
1449 byte* address_; // The address of the code being patched. | 1456 byte* address_; // The address of the code being patched. |
1450 int size_; // Number of bytes of the expected patch size. | 1457 int size_; // Number of bytes of the expected patch size. |
1451 MacroAssembler masm_; // Macro assembler used to generate the code. | 1458 MacroAssembler masm_; // Macro assembler used to generate the code. |
| 1459 FlushICache flush_cache_; // Whether to flush the I cache after patching. |
1452 }; | 1460 }; |
1453 | 1461 |
1454 | 1462 |
1455 // ----------------------------------------------------------------------------- | 1463 // ----------------------------------------------------------------------------- |
1456 // Static helper functions. | 1464 // Static helper functions. |
1457 | 1465 |
1458 inline MemOperand ContextOperand(Register context, int index) { | 1466 inline MemOperand ContextOperand(Register context, int index) { |
1459 return MemOperand(context, Context::SlotOffset(index)); | 1467 return MemOperand(context, Context::SlotOffset(index)); |
1460 } | 1468 } |
1461 | 1469 |
1462 | 1470 |
1463 inline MemOperand GlobalObjectOperand() { | 1471 inline MemOperand GlobalObjectOperand() { |
1464 return ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX); | 1472 return ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX); |
1465 } | 1473 } |
1466 | 1474 |
1467 | 1475 |
1468 #ifdef GENERATED_CODE_COVERAGE | 1476 #ifdef GENERATED_CODE_COVERAGE |
1469 #define CODE_COVERAGE_STRINGIFY(x) #x | 1477 #define CODE_COVERAGE_STRINGIFY(x) #x |
1470 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1478 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
1471 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1479 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
1472 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1480 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
1473 #else | 1481 #else |
1474 #define ACCESS_MASM(masm) masm-> | 1482 #define ACCESS_MASM(masm) masm-> |
1475 #endif | 1483 #endif |
1476 | 1484 |
1477 | 1485 |
1478 } } // namespace v8::internal | 1486 } } // namespace v8::internal |
1479 | 1487 |
1480 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 1488 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
OLD | NEW |