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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 info_emitted_ = false; | 57 info_emitted_ = false; |
58 #endif | 58 #endif |
59 } | 59 } |
60 | 60 |
61 ~JumpPatchSite() { | 61 ~JumpPatchSite() { |
62 ASSERT(patch_site_.is_bound() == info_emitted_); | 62 ASSERT(patch_site_.is_bound() == info_emitted_); |
63 } | 63 } |
64 | 64 |
65 void EmitJumpIfNotSmi(Register reg, | 65 void EmitJumpIfNotSmi(Register reg, |
66 Label* target, | 66 Label* target, |
67 Label::Distance near = Label::kFar) { | 67 Label::Distance distance = Label::kFar) { |
68 __ test(reg, Immediate(kSmiTagMask)); | 68 __ test(reg, Immediate(kSmiTagMask)); |
69 EmitJump(not_carry, target, near); // Always taken before patched. | 69 EmitJump(not_carry, target, distance); // Always taken before patched. |
70 } | 70 } |
71 | 71 |
72 void EmitJumpIfSmi(Register reg, | 72 void EmitJumpIfSmi(Register reg, |
73 Label* target, | 73 Label* target, |
74 Label::Distance near = Label::kFar) { | 74 Label::Distance distance = Label::kFar) { |
75 __ test(reg, Immediate(kSmiTagMask)); | 75 __ test(reg, Immediate(kSmiTagMask)); |
76 EmitJump(carry, target, near); // Never taken before patched. | 76 EmitJump(carry, target, distance); // Never taken before patched. |
77 } | 77 } |
78 | 78 |
79 void EmitPatchInfo() { | 79 void EmitPatchInfo() { |
80 int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(&patch_site_); | 80 int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(&patch_site_); |
81 ASSERT(is_int8(delta_to_patch_site)); | 81 ASSERT(is_int8(delta_to_patch_site)); |
82 __ test(eax, Immediate(delta_to_patch_site)); | 82 __ test(eax, Immediate(delta_to_patch_site)); |
83 #ifdef DEBUG | 83 #ifdef DEBUG |
84 info_emitted_ = true; | 84 info_emitted_ = true; |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
88 bool is_bound() const { return patch_site_.is_bound(); } | 88 bool is_bound() const { return patch_site_.is_bound(); } |
89 | 89 |
90 private: | 90 private: |
91 // jc will be patched with jz, jnc will become jnz. | 91 // jc will be patched with jz, jnc will become jnz. |
92 void EmitJump(Condition cc, Label* target, Label::Distance near) { | 92 void EmitJump(Condition cc, Label* target, Label::Distance distance) { |
93 ASSERT(!patch_site_.is_bound() && !info_emitted_); | 93 ASSERT(!patch_site_.is_bound() && !info_emitted_); |
94 ASSERT(cc == carry || cc == not_carry); | 94 ASSERT(cc == carry || cc == not_carry); |
95 __ bind(&patch_site_); | 95 __ bind(&patch_site_); |
96 __ j(cc, target, near); | 96 __ j(cc, target, distance); |
97 } | 97 } |
98 | 98 |
99 MacroAssembler* masm_; | 99 MacroAssembler* masm_; |
100 Label patch_site_; | 100 Label patch_site_; |
101 #ifdef DEBUG | 101 #ifdef DEBUG |
102 bool info_emitted_; | 102 bool info_emitted_; |
103 #endif | 103 #endif |
104 }; | 104 }; |
105 | 105 |
106 | 106 |
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4322 // And return. | 4322 // And return. |
4323 __ ret(0); | 4323 __ ret(0); |
4324 } | 4324 } |
4325 | 4325 |
4326 | 4326 |
4327 #undef __ | 4327 #undef __ |
4328 | 4328 |
4329 } } // namespace v8::internal | 4329 } } // namespace v8::internal |
4330 | 4330 |
4331 #endif // V8_TARGET_ARCH_IA32 | 4331 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |