OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 22 matching lines...) Expand all Loading... |
33 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
34 #include "assembler-x64.h" | 34 #include "assembler-x64.h" |
35 #include "macro-assembler-x64.h" | 35 #include "macro-assembler-x64.h" |
36 #include "serialize.h" | 36 #include "serialize.h" |
37 #include "debug.h" | 37 #include "debug.h" |
38 #include "heap.h" | 38 #include "heap.h" |
39 | 39 |
40 namespace v8 { | 40 namespace v8 { |
41 namespace internal { | 41 namespace internal { |
42 | 42 |
43 MacroAssembler::MacroAssembler(void* buffer, int size) | 43 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
44 : Assembler(Isolate::Current(), buffer, size), | 44 : Assembler(arg_isolate, buffer, size), |
45 generating_stub_(false), | 45 generating_stub_(false), |
46 allow_stub_calls_(true), | 46 allow_stub_calls_(true), |
47 root_array_available_(true), | 47 root_array_available_(true) { |
48 code_object_(isolate()->heap()->undefined_value()) { | 48 if (isolate() != NULL) { |
| 49 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 50 isolate()); |
| 51 } |
49 } | 52 } |
50 | 53 |
51 | 54 |
52 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) { | 55 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) { |
53 Address roots_register_value = kRootRegisterBias + | 56 Address roots_register_value = kRootRegisterBias + |
54 reinterpret_cast<Address>(isolate->heap()->roots_address()); | 57 reinterpret_cast<Address>(isolate->heap()->roots_address()); |
55 intptr_t delta = other.address() - roots_register_value; | 58 intptr_t delta = other.address() - roots_register_value; |
56 return delta; | 59 return delta; |
57 } | 60 } |
58 | 61 |
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2878 call(function); | 2881 call(function); |
2879 ASSERT(OS::ActivationFrameAlignment() != 0); | 2882 ASSERT(OS::ActivationFrameAlignment() != 0); |
2880 ASSERT(num_arguments >= 0); | 2883 ASSERT(num_arguments >= 0); |
2881 int argument_slots_on_stack = | 2884 int argument_slots_on_stack = |
2882 ArgumentStackSlotsForCFunctionCall(num_arguments); | 2885 ArgumentStackSlotsForCFunctionCall(num_arguments); |
2883 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); | 2886 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); |
2884 } | 2887 } |
2885 | 2888 |
2886 | 2889 |
2887 CodePatcher::CodePatcher(byte* address, int size) | 2890 CodePatcher::CodePatcher(byte* address, int size) |
2888 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { | 2891 : address_(address), |
| 2892 size_(size), |
| 2893 masm_(Isolate::Current(), address, size + Assembler::kGap) { |
2889 // Create a new macro assembler pointing to the address of the code to patch. | 2894 // Create a new macro assembler pointing to the address of the code to patch. |
2890 // The size is adjusted with kGap on order for the assembler to generate size | 2895 // The size is adjusted with kGap on order for the assembler to generate size |
2891 // bytes of instructions without failing with buffer size constraints. | 2896 // bytes of instructions without failing with buffer size constraints. |
2892 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2897 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2893 } | 2898 } |
2894 | 2899 |
2895 | 2900 |
2896 CodePatcher::~CodePatcher() { | 2901 CodePatcher::~CodePatcher() { |
2897 // Indicate that code has changed. | 2902 // Indicate that code has changed. |
2898 CPU::FlushICache(address_, size_); | 2903 CPU::FlushICache(address_, size_); |
2899 | 2904 |
2900 // Check that the code was patched as expected. | 2905 // Check that the code was patched as expected. |
2901 ASSERT(masm_.pc_ == address_ + size_); | 2906 ASSERT(masm_.pc_ == address_ + size_); |
2902 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2907 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2903 } | 2908 } |
2904 | 2909 |
2905 } } // namespace v8::internal | 2910 } } // namespace v8::internal |
2906 | 2911 |
2907 #endif // V8_TARGET_ARCH_X64 | 2912 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |