danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 1 | // Copyright (c) 1994-2006 Sun Microsystems Inc. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // All Rights Reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions are |
| 6 | // met: |
| 7 | // |
| 8 | // - Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions and the following disclaimer. |
| 10 | // |
| 11 | // - Redistribution in binary form must reproduce the above copyright |
| 12 | // notice, this list of conditions and the following disclaimer in the |
| 13 | // documentation and/or other materials provided with the distribution. |
| 14 | // |
| 15 | // - Neither the name of Sun Microsystems or the names of contributors may |
| 16 | // be used to endorse or promote products derived from this software without |
| 17 | // specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 20 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 21 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 23 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 24 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 25 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 26 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 27 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 28 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | // The original source code covered by the above license above has been |
| 32 | // modified significantly by Google Inc. |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame^] | 33 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame^] | 35 | #include "assembler.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 36 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame^] | 37 | #include <math.h> // For cos, log, pow, sin, tan, etc. |
| 38 | #include "api.h" |
| 39 | #include "builtins.h" |
| 40 | #include "counters.h" |
| 41 | #include "cpu.h" |
| 42 | #include "debug.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 43 | #include "deoptimizer.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | #include "execution.h" |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame^] | 45 | #include "ic.h" |
| 46 | #include "isolate.h" |
| 47 | #include "jsregexp.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 48 | #include "platform.h" |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame^] | 49 | #include "regexp-macro-assembler.h" |
| 50 | #include "regexp-stack.h" |
| 51 | #include "runtime.h" |
| 52 | #include "serialize.h" |
| 53 | #include "store-buffer-inl.h" |
| 54 | #include "stub-cache.h" |
| 55 | #include "token.h" |
| 56 | |
| 57 | #if V8_TARGET_ARCH_IA32 |
| 58 | #include "ia32/assembler-ia32-inl.h" |
| 59 | #elif V8_TARGET_ARCH_X64 |
| 60 | #include "x64/assembler-x64-inl.h" |
| 61 | #elif V8_TARGET_ARCH_ARM |
| 62 | #include "arm/assembler-arm-inl.h" |
| 63 | #elif V8_TARGET_ARCH_MIPS |
| 64 | #include "mips/assembler-mips-inl.h" |
| 65 | #else |
| 66 | #error "Unknown architecture." |
| 67 | #endif |
| 68 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 69 | // Include native regexp-macro-assembler. |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 70 | #ifndef V8_INTERPRETED_REGEXP |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 71 | #if V8_TARGET_ARCH_IA32 |
| 72 | #include "ia32/regexp-macro-assembler-ia32.h" |
| 73 | #elif V8_TARGET_ARCH_X64 |
| 74 | #include "x64/regexp-macro-assembler-x64.h" |
| 75 | #elif V8_TARGET_ARCH_ARM |
| 76 | #include "arm/regexp-macro-assembler-arm.h" |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 77 | #elif V8_TARGET_ARCH_MIPS |
| 78 | #include "mips/regexp-macro-assembler-mips.h" |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 79 | #else // Unknown architecture. |
| 80 | #error "Unknown architecture." |
| 81 | #endif // Target architecture. |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 82 | #endif // V8_INTERPRETED_REGEXP |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 83 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 84 | namespace v8 { |
| 85 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 86 | |
| 87 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 88 | const double DoubleConstant::min_int = kMinInt; |
| 89 | const double DoubleConstant::one_half = 0.5; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 90 | const double DoubleConstant::minus_zero = -0.0; |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 91 | const double DoubleConstant::uint8_max_value = 255; |
| 92 | const double DoubleConstant::zero = 0.0; |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 93 | const double DoubleConstant::canonical_non_hole_nan = OS::nan_value(); |
| 94 | const double DoubleConstant::the_hole_nan = BitCast<double>(kHoleNanInt64); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 95 | const double DoubleConstant::negative_infinity = -V8_INFINITY; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 96 | const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 97 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 98 | // ----------------------------------------------------------------------------- |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 99 | // Implementation of AssemblerBase |
| 100 | |
| 101 | AssemblerBase::AssemblerBase(Isolate* isolate) |
| 102 | : isolate_(isolate), |
| 103 | jit_cookie_(0) { |
| 104 | if (FLAG_mask_constants_with_cookie && isolate != NULL) { |
| 105 | jit_cookie_ = V8::RandomPrivate(isolate); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | |
| 110 | // ----------------------------------------------------------------------------- |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 111 | // Implementation of Label |
| 112 | |
| 113 | int Label::pos() const { |
| 114 | if (pos_ < 0) return -pos_ - 1; |
| 115 | if (pos_ > 0) return pos_ - 1; |
| 116 | UNREACHABLE(); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | // ----------------------------------------------------------------------------- |
| 122 | // Implementation of RelocInfoWriter and RelocIterator |
| 123 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 124 | // Relocation information is written backwards in memory, from high addresses |
| 125 | // towards low addresses, byte by byte. Therefore, in the encodings listed |
| 126 | // below, the first byte listed it at the highest address, and successive |
| 127 | // bytes in the record are at progressively lower addresses. |
| 128 | // |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 129 | // Encoding |
| 130 | // |
| 131 | // The most common modes are given single-byte encodings. Also, it is |
| 132 | // easy to identify the type of reloc info and skip unwanted modes in |
| 133 | // an iteration. |
| 134 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 135 | // The encoding relies on the fact that there are fewer than 14 |
| 136 | // different non-compactly encoded relocation modes. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 137 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 138 | // The first byte of a relocation record has a tag in its low 2 bits: |
| 139 | // Here are the record schemes, depending on the low tag and optional higher |
| 140 | // tags. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 142 | // Low tag: |
| 143 | // 00: embedded_object: [6-bit pc delta] 00 |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 144 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 145 | // 01: code_target: [6-bit pc delta] 01 |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 146 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 147 | // 10: short_data_record: [6-bit pc delta] 10 followed by |
| 148 | // [6-bit data delta] [2-bit data type tag] |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 149 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 150 | // 11: long_record [2-bit high tag][4 bit middle_tag] 11 |
| 151 | // followed by variable data depending on type. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 152 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 153 | // 2-bit data type tags, used in short_data_record and data_jump long_record: |
| 154 | // code_target_with_id: 00 |
| 155 | // position: 01 |
| 156 | // statement_position: 10 |
| 157 | // comment: 11 (not used in short_data_record) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 158 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 159 | // Long record format: |
| 160 | // 4-bit middle_tag: |
| 161 | // 0000 - 1100 : Short record for RelocInfo::Mode middle_tag + 2 |
| 162 | // (The middle_tag encodes rmode - RelocInfo::LAST_COMPACT_ENUM, |
| 163 | // and is between 0000 and 1100) |
| 164 | // The format is: |
| 165 | // 00 [4 bit middle_tag] 11 followed by |
| 166 | // 00 [6 bit pc delta] |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 167 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 168 | // 1101: not used (would allow one more relocation mode to be added) |
| 169 | // 1110: long_data_record |
| 170 | // The format is: [2-bit data_type_tag] 1110 11 |
| 171 | // signed intptr_t, lowest byte written first |
| 172 | // (except data_type code_target_with_id, which |
| 173 | // is followed by a signed int, not intptr_t.) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 174 | // |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 175 | // 1111: long_pc_jump |
| 176 | // The format is: |
| 177 | // pc-jump: 00 1111 11, |
| 178 | // 00 [6 bits pc delta] |
| 179 | // or |
| 180 | // pc-jump (variable length): |
| 181 | // 01 1111 11, |
| 182 | // [7 bits data] 0 |
| 183 | // ... |
| 184 | // [7 bits data] 1 |
| 185 | // (Bits 6..31 of pc delta, with leading zeroes |
| 186 | // dropped, and last non-zero chunk tagged with 1.) |
| 187 | |
| 188 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 189 | const int kMaxRelocModes = 14; |
| 190 | |
| 191 | const int kTagBits = 2; |
| 192 | const int kTagMask = (1 << kTagBits) - 1; |
| 193 | const int kExtraTagBits = 4; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 194 | const int kLocatableTypeTagBits = 2; |
| 195 | const int kSmallDataBits = kBitsPerByte - kLocatableTypeTagBits; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 196 | |
| 197 | const int kEmbeddedObjectTag = 0; |
| 198 | const int kCodeTargetTag = 1; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 199 | const int kLocatableTag = 2; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 200 | const int kDefaultTag = 3; |
| 201 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 202 | const int kPCJumpExtraTag = (1 << kExtraTagBits) - 1; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 203 | |
| 204 | const int kSmallPCDeltaBits = kBitsPerByte - kTagBits; |
| 205 | const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1; |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 206 | const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 207 | |
| 208 | const int kVariableLengthPCJumpTopTag = 1; |
| 209 | const int kChunkBits = 7; |
| 210 | const int kChunkMask = (1 << kChunkBits) - 1; |
| 211 | const int kLastChunkTagBits = 1; |
| 212 | const int kLastChunkTagMask = 1; |
| 213 | const int kLastChunkTag = 1; |
| 214 | |
| 215 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 216 | const int kDataJumpExtraTag = kPCJumpExtraTag - 1; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 217 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 218 | const int kCodeWithIdTag = 0; |
| 219 | const int kNonstatementPositionTag = 1; |
| 220 | const int kStatementPositionTag = 2; |
| 221 | const int kCommentTag = 3; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 222 | |
| 223 | |
| 224 | uint32_t RelocInfoWriter::WriteVariableLengthPCJump(uint32_t pc_delta) { |
| 225 | // Return if the pc_delta can fit in kSmallPCDeltaBits bits. |
| 226 | // Otherwise write a variable length PC jump for the bits that do |
| 227 | // not fit in the kSmallPCDeltaBits bits. |
| 228 | if (is_uintn(pc_delta, kSmallPCDeltaBits)) return pc_delta; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 229 | WriteExtraTag(kPCJumpExtraTag, kVariableLengthPCJumpTopTag); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 230 | uint32_t pc_jump = pc_delta >> kSmallPCDeltaBits; |
| 231 | ASSERT(pc_jump > 0); |
| 232 | // Write kChunkBits size chunks of the pc_jump. |
| 233 | for (; pc_jump > 0; pc_jump = pc_jump >> kChunkBits) { |
| 234 | byte b = pc_jump & kChunkMask; |
| 235 | *--pos_ = b << kLastChunkTagBits; |
| 236 | } |
| 237 | // Tag the last chunk so it can be identified. |
| 238 | *pos_ = *pos_ | kLastChunkTag; |
| 239 | // Return the remaining kSmallPCDeltaBits of the pc_delta. |
| 240 | return pc_delta & kSmallPCDeltaMask; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | void RelocInfoWriter::WriteTaggedPC(uint32_t pc_delta, int tag) { |
| 245 | // Write a byte of tagged pc-delta, possibly preceded by var. length pc-jump. |
| 246 | pc_delta = WriteVariableLengthPCJump(pc_delta); |
| 247 | *--pos_ = pc_delta << kTagBits | tag; |
| 248 | } |
| 249 | |
| 250 | |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 251 | void RelocInfoWriter::WriteTaggedData(intptr_t data_delta, int tag) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 252 | *--pos_ = static_cast<byte>(data_delta << kLocatableTypeTagBits | tag); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | |
| 256 | void RelocInfoWriter::WriteExtraTag(int extra_tag, int top_tag) { |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 257 | *--pos_ = static_cast<int>(top_tag << (kTagBits + kExtraTagBits) | |
| 258 | extra_tag << kTagBits | |
| 259 | kDefaultTag); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | |
| 263 | void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) { |
| 264 | // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump. |
| 265 | pc_delta = WriteVariableLengthPCJump(pc_delta); |
| 266 | WriteExtraTag(extra_tag, 0); |
| 267 | *--pos_ = pc_delta; |
| 268 | } |
| 269 | |
| 270 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 271 | void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) { |
| 272 | WriteExtraTag(kDataJumpExtraTag, top_tag); |
| 273 | for (int i = 0; i < kIntSize; i++) { |
| 274 | *--pos_ = static_cast<byte>(data_delta); |
| 275 | // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
| 276 | data_delta = data_delta >> kBitsPerByte; |
| 277 | } |
| 278 | } |
| 279 | |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 280 | void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 281 | WriteExtraTag(kDataJumpExtraTag, top_tag); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 282 | for (int i = 0; i < kIntptrSize; i++) { |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 283 | *--pos_ = static_cast<byte>(data_delta); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 284 | // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 285 | data_delta = data_delta >> kBitsPerByte; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | |
| 289 | |
| 290 | void RelocInfoWriter::Write(const RelocInfo* rinfo) { |
| 291 | #ifdef DEBUG |
| 292 | byte* begin_pos = pos_; |
| 293 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 294 | ASSERT(rinfo->pc() - last_pc_ >= 0); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 295 | ASSERT(RelocInfo::NUMBER_OF_MODES - RelocInfo::LAST_COMPACT_ENUM <= |
| 296 | kMaxRelocModes); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 297 | // Use unsigned delta-encoding for pc. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 298 | uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 299 | RelocInfo::Mode rmode = rinfo->rmode(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 300 | |
| 301 | // The two most common modes are given small tags, and usually fit in a byte. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 302 | if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 303 | WriteTaggedPC(pc_delta, kEmbeddedObjectTag); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 304 | } else if (rmode == RelocInfo::CODE_TARGET) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 305 | WriteTaggedPC(pc_delta, kCodeTargetTag); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 306 | ASSERT(begin_pos - pos_ <= RelocInfo::kMaxCallSize); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 307 | } else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
| 308 | // Use signed delta-encoding for id. |
| 309 | ASSERT(static_cast<int>(rinfo->data()) == rinfo->data()); |
| 310 | int id_delta = static_cast<int>(rinfo->data()) - last_id_; |
| 311 | // Check if delta is small enough to fit in a tagged byte. |
| 312 | if (is_intn(id_delta, kSmallDataBits)) { |
| 313 | WriteTaggedPC(pc_delta, kLocatableTag); |
| 314 | WriteTaggedData(id_delta, kCodeWithIdTag); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 315 | } else { |
| 316 | // Otherwise, use costly encoding. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 317 | WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 318 | WriteExtraTaggedIntData(id_delta, kCodeWithIdTag); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 319 | } |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 320 | last_id_ = static_cast<int>(rinfo->data()); |
| 321 | } else if (RelocInfo::IsPosition(rmode)) { |
| 322 | // Use signed delta-encoding for position. |
| 323 | ASSERT(static_cast<int>(rinfo->data()) == rinfo->data()); |
| 324 | int pos_delta = static_cast<int>(rinfo->data()) - last_position_; |
| 325 | int pos_type_tag = (rmode == RelocInfo::POSITION) ? kNonstatementPositionTag |
| 326 | : kStatementPositionTag; |
| 327 | // Check if delta is small enough to fit in a tagged byte. |
| 328 | if (is_intn(pos_delta, kSmallDataBits)) { |
| 329 | WriteTaggedPC(pc_delta, kLocatableTag); |
| 330 | WriteTaggedData(pos_delta, pos_type_tag); |
| 331 | } else { |
| 332 | // Otherwise, use costly encoding. |
| 333 | WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 334 | WriteExtraTaggedIntData(pos_delta, pos_type_tag); |
| 335 | } |
| 336 | last_position_ = static_cast<int>(rinfo->data()); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 337 | } else if (RelocInfo::IsComment(rmode)) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 338 | // Comments are normally not generated, so we use the costly encoding. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 339 | WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag); |
| 340 | WriteExtraTaggedData(rinfo->data(), kCommentTag); |
ricow@chromium.org | 2233451 | 2011-02-25 07:28:50 +0000 | [diff] [blame] | 341 | ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 342 | } else { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 343 | ASSERT(rmode > RelocInfo::LAST_COMPACT_ENUM); |
| 344 | int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 345 | // For all other modes we simply use the mode as the extra tag. |
| 346 | // None of these modes need a data component. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 347 | ASSERT(saved_mode < kPCJumpExtraTag && saved_mode < kDataJumpExtraTag); |
| 348 | WriteExtraTaggedPC(pc_delta, saved_mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 349 | } |
| 350 | last_pc_ = rinfo->pc(); |
| 351 | #ifdef DEBUG |
| 352 | ASSERT(begin_pos - pos_ <= kMaxSize); |
| 353 | #endif |
| 354 | } |
| 355 | |
| 356 | |
| 357 | inline int RelocIterator::AdvanceGetTag() { |
| 358 | return *--pos_ & kTagMask; |
| 359 | } |
| 360 | |
| 361 | |
| 362 | inline int RelocIterator::GetExtraTag() { |
| 363 | return (*pos_ >> kTagBits) & ((1 << kExtraTagBits) - 1); |
| 364 | } |
| 365 | |
| 366 | |
| 367 | inline int RelocIterator::GetTopTag() { |
| 368 | return *pos_ >> (kTagBits + kExtraTagBits); |
| 369 | } |
| 370 | |
| 371 | |
| 372 | inline void RelocIterator::ReadTaggedPC() { |
| 373 | rinfo_.pc_ += *pos_ >> kTagBits; |
| 374 | } |
| 375 | |
| 376 | |
| 377 | inline void RelocIterator::AdvanceReadPC() { |
| 378 | rinfo_.pc_ += *--pos_; |
| 379 | } |
| 380 | |
| 381 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 382 | void RelocIterator::AdvanceReadId() { |
| 383 | int x = 0; |
| 384 | for (int i = 0; i < kIntSize; i++) { |
| 385 | x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
| 386 | } |
| 387 | last_id_ += x; |
| 388 | rinfo_.data_ = last_id_; |
| 389 | } |
| 390 | |
| 391 | |
| 392 | void RelocIterator::AdvanceReadPosition() { |
| 393 | int x = 0; |
| 394 | for (int i = 0; i < kIntSize; i++) { |
| 395 | x |= static_cast<int>(*--pos_) << i * kBitsPerByte; |
| 396 | } |
| 397 | last_position_ += x; |
| 398 | rinfo_.data_ = last_position_; |
| 399 | } |
| 400 | |
| 401 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 402 | void RelocIterator::AdvanceReadData() { |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 403 | intptr_t x = 0; |
| 404 | for (int i = 0; i < kIntptrSize; i++) { |
| 405 | x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 406 | } |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 407 | rinfo_.data_ = x; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | |
| 411 | void RelocIterator::AdvanceReadVariableLengthPCJump() { |
| 412 | // Read the 32-kSmallPCDeltaBits most significant bits of the |
| 413 | // pc jump in kChunkBits bit chunks and shift them into place. |
| 414 | // Stop when the last chunk is encountered. |
| 415 | uint32_t pc_jump = 0; |
| 416 | for (int i = 0; i < kIntSize; i++) { |
| 417 | byte pc_jump_part = *--pos_; |
| 418 | pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits; |
| 419 | if ((pc_jump_part & kLastChunkTagMask) == 1) break; |
| 420 | } |
| 421 | // The least significant kSmallPCDeltaBits bits will be added |
| 422 | // later. |
| 423 | rinfo_.pc_ += pc_jump << kSmallPCDeltaBits; |
| 424 | } |
| 425 | |
| 426 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 427 | inline int RelocIterator::GetLocatableTypeTag() { |
| 428 | return *pos_ & ((1 << kLocatableTypeTagBits) - 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 432 | inline void RelocIterator::ReadTaggedId() { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 433 | int8_t signed_b = *pos_; |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 434 | // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 435 | last_id_ += signed_b >> kLocatableTypeTagBits; |
| 436 | rinfo_.data_ = last_id_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 440 | inline void RelocIterator::ReadTaggedPosition() { |
| 441 | int8_t signed_b = *pos_; |
| 442 | // Signed right shift is arithmetic shift. Tested in test-utils.cc. |
| 443 | last_position_ += signed_b >> kLocatableTypeTagBits; |
| 444 | rinfo_.data_ = last_position_; |
| 445 | } |
| 446 | |
| 447 | |
| 448 | static inline RelocInfo::Mode GetPositionModeFromTag(int tag) { |
| 449 | ASSERT(tag == kNonstatementPositionTag || |
| 450 | tag == kStatementPositionTag); |
| 451 | return (tag == kNonstatementPositionTag) ? |
| 452 | RelocInfo::POSITION : |
| 453 | RelocInfo::STATEMENT_POSITION; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | |
| 457 | void RelocIterator::next() { |
| 458 | ASSERT(!done()); |
| 459 | // Basically, do the opposite of RelocInfoWriter::Write. |
| 460 | // Reading of data is as far as possible avoided for unwanted modes, |
| 461 | // but we must always update the pc. |
| 462 | // |
| 463 | // We exit this loop by returning when we find a mode we want. |
| 464 | while (pos_ > end_) { |
| 465 | int tag = AdvanceGetTag(); |
| 466 | if (tag == kEmbeddedObjectTag) { |
| 467 | ReadTaggedPC(); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 468 | if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 469 | } else if (tag == kCodeTargetTag) { |
| 470 | ReadTaggedPC(); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 471 | if (SetMode(RelocInfo::CODE_TARGET)) return; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 472 | } else if (tag == kLocatableTag) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 473 | ReadTaggedPC(); |
| 474 | Advance(); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 475 | int locatable_tag = GetLocatableTypeTag(); |
| 476 | if (locatable_tag == kCodeWithIdTag) { |
| 477 | if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { |
| 478 | ReadTaggedId(); |
| 479 | return; |
| 480 | } |
| 481 | } else { |
| 482 | // Compact encoding is never used for comments, |
| 483 | // so it must be a position. |
| 484 | ASSERT(locatable_tag == kNonstatementPositionTag || |
| 485 | locatable_tag == kStatementPositionTag); |
| 486 | if (mode_mask_ & RelocInfo::kPositionMask) { |
| 487 | ReadTaggedPosition(); |
| 488 | if (SetMode(GetPositionModeFromTag(locatable_tag))) return; |
| 489 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 490 | } |
| 491 | } else { |
| 492 | ASSERT(tag == kDefaultTag); |
| 493 | int extra_tag = GetExtraTag(); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 494 | if (extra_tag == kPCJumpExtraTag) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 495 | int top_tag = GetTopTag(); |
| 496 | if (top_tag == kVariableLengthPCJumpTopTag) { |
| 497 | AdvanceReadVariableLengthPCJump(); |
| 498 | } else { |
| 499 | AdvanceReadPC(); |
| 500 | } |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 501 | } else if (extra_tag == kDataJumpExtraTag) { |
| 502 | int locatable_tag = GetTopTag(); |
| 503 | if (locatable_tag == kCodeWithIdTag) { |
| 504 | if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) { |
| 505 | AdvanceReadId(); |
| 506 | return; |
| 507 | } |
| 508 | Advance(kIntSize); |
| 509 | } else if (locatable_tag != kCommentTag) { |
| 510 | ASSERT(locatable_tag == kNonstatementPositionTag || |
| 511 | locatable_tag == kStatementPositionTag); |
| 512 | if (mode_mask_ & RelocInfo::kPositionMask) { |
| 513 | AdvanceReadPosition(); |
| 514 | if (SetMode(GetPositionModeFromTag(locatable_tag))) return; |
| 515 | } else { |
| 516 | Advance(kIntSize); |
| 517 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 518 | } else { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 519 | ASSERT(locatable_tag == kCommentTag); |
| 520 | if (SetMode(RelocInfo::COMMENT)) { |
| 521 | AdvanceReadData(); |
| 522 | return; |
| 523 | } |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 524 | Advance(kIntptrSize); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 525 | } |
| 526 | } else { |
| 527 | AdvanceReadPC(); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 528 | int rmode = extra_tag + RelocInfo::LAST_COMPACT_ENUM; |
| 529 | if (SetMode(static_cast<RelocInfo::Mode>(rmode))) return; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | } |
| 533 | done_ = true; |
| 534 | } |
| 535 | |
| 536 | |
| 537 | RelocIterator::RelocIterator(Code* code, int mode_mask) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 538 | rinfo_.host_ = code; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 539 | rinfo_.pc_ = code->instruction_start(); |
| 540 | rinfo_.data_ = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 541 | // Relocation info is read backwards. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 542 | pos_ = code->relocation_start() + code->relocation_size(); |
| 543 | end_ = code->relocation_start(); |
| 544 | done_ = false; |
| 545 | mode_mask_ = mode_mask; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 546 | last_id_ = 0; |
| 547 | last_position_ = 0; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 548 | if (mode_mask_ == 0) pos_ = end_; |
| 549 | next(); |
| 550 | } |
| 551 | |
| 552 | |
| 553 | RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { |
| 554 | rinfo_.pc_ = desc.buffer; |
| 555 | rinfo_.data_ = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 556 | // Relocation info is read backwards. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 557 | pos_ = desc.buffer + desc.buffer_size; |
| 558 | end_ = pos_ - desc.reloc_size; |
| 559 | done_ = false; |
| 560 | mode_mask_ = mode_mask; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 561 | last_id_ = 0; |
| 562 | last_position_ = 0; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 563 | if (mode_mask_ == 0) pos_ = end_; |
| 564 | next(); |
| 565 | } |
| 566 | |
| 567 | |
| 568 | // ----------------------------------------------------------------------------- |
| 569 | // Implementation of RelocInfo |
| 570 | |
| 571 | |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 572 | #ifdef ENABLE_DISASSEMBLER |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 573 | const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 574 | switch (rmode) { |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 575 | case RelocInfo::NONE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 576 | return "no reloc"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 577 | case RelocInfo::EMBEDDED_OBJECT: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 578 | return "embedded object"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 579 | case RelocInfo::CONSTRUCT_CALL: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 580 | return "code target (js construct call)"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 581 | case RelocInfo::CODE_TARGET_CONTEXT: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 582 | return "code target (context)"; |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 583 | case RelocInfo::DEBUG_BREAK: |
| 584 | #ifndef ENABLE_DEBUGGER_SUPPORT |
| 585 | UNREACHABLE(); |
| 586 | #endif |
| 587 | return "debug break"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 588 | case RelocInfo::CODE_TARGET: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 589 | return "code target"; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 590 | case RelocInfo::CODE_TARGET_WITH_ID: |
| 591 | return "code target with id"; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 592 | case RelocInfo::GLOBAL_PROPERTY_CELL: |
| 593 | return "global property cell"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 594 | case RelocInfo::RUNTIME_ENTRY: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 595 | return "runtime entry"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 596 | case RelocInfo::JS_RETURN: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 597 | return "js return"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 598 | case RelocInfo::COMMENT: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 599 | return "comment"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 600 | case RelocInfo::POSITION: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 601 | return "position"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 602 | case RelocInfo::STATEMENT_POSITION: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 603 | return "statement position"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 604 | case RelocInfo::EXTERNAL_REFERENCE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 605 | return "external reference"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 606 | case RelocInfo::INTERNAL_REFERENCE: |
| 607 | return "internal reference"; |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 608 | case RelocInfo::DEBUG_BREAK_SLOT: |
| 609 | #ifndef ENABLE_DEBUGGER_SUPPORT |
| 610 | UNREACHABLE(); |
| 611 | #endif |
| 612 | return "debug break slot"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 613 | case RelocInfo::NUMBER_OF_MODES: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 614 | UNREACHABLE(); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 615 | return "number_of_modes"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 616 | } |
| 617 | return "unknown relocation type"; |
| 618 | } |
| 619 | |
| 620 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 621 | void RelocInfo::Print(FILE* out) { |
| 622 | PrintF(out, "%p %s", pc_, RelocModeName(rmode_)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 623 | if (IsComment(rmode_)) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 624 | PrintF(out, " (%s)", reinterpret_cast<char*>(data_)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 625 | } else if (rmode_ == EMBEDDED_OBJECT) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 626 | PrintF(out, " ("); |
| 627 | target_object()->ShortPrint(out); |
| 628 | PrintF(out, ")"); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 629 | } else if (rmode_ == EXTERNAL_REFERENCE) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 630 | ExternalReferenceEncoder ref_encoder; |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 631 | PrintF(out, " (%s) (%p)", |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 632 | ref_encoder.NameOfAddress(*target_reference_address()), |
| 633 | *target_reference_address()); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 634 | } else if (IsCodeTarget(rmode_)) { |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 635 | Code* code = Code::GetCodeFromTargetAddress(target_address()); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 636 | PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()), |
| 637 | target_address()); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 638 | if (rmode_ == CODE_TARGET_WITH_ID) { |
| 639 | PrintF(" (id=%d)", static_cast<int>(data_)); |
| 640 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 641 | } else if (IsPosition(rmode_)) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 642 | PrintF(out, " (%" V8_PTR_PREFIX "d)", data()); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 643 | } else if (rmode_ == RelocInfo::RUNTIME_ENTRY && |
| 644 | Isolate::Current()->deoptimizer_data() != NULL) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 645 | // Depotimization bailouts are stored as runtime entries. |
| 646 | int id = Deoptimizer::GetDeoptimizationId( |
| 647 | target_address(), Deoptimizer::EAGER); |
| 648 | if (id != Deoptimizer::kNotDeoptimizationEntry) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 649 | PrintF(out, " (deoptimization bailout %d)", id); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 650 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 651 | } |
| 652 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 653 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 654 | } |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 655 | #endif // ENABLE_DISASSEMBLER |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 656 | |
| 657 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 658 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 659 | void RelocInfo::Verify() { |
| 660 | switch (rmode_) { |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 661 | case EMBEDDED_OBJECT: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 662 | Object::VerifyPointer(target_object()); |
| 663 | break; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 664 | case GLOBAL_PROPERTY_CELL: |
| 665 | Object::VerifyPointer(target_cell()); |
| 666 | break; |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 667 | case DEBUG_BREAK: |
| 668 | #ifndef ENABLE_DEBUGGER_SUPPORT |
| 669 | UNREACHABLE(); |
| 670 | break; |
| 671 | #endif |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 672 | case CONSTRUCT_CALL: |
| 673 | case CODE_TARGET_CONTEXT: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 674 | case CODE_TARGET_WITH_ID: |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 675 | case CODE_TARGET: { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 676 | // convert inline target address to code object |
| 677 | Address addr = target_address(); |
| 678 | ASSERT(addr != NULL); |
| 679 | // Check that we can find the right code object. |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 680 | Code* code = Code::GetCodeFromTargetAddress(addr); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 681 | Object* found = HEAP->FindCodeObject(addr); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 682 | ASSERT(found->IsCode()); |
| 683 | ASSERT(code->address() == HeapObject::cast(found)->address()); |
| 684 | break; |
| 685 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 686 | case RUNTIME_ENTRY: |
| 687 | case JS_RETURN: |
| 688 | case COMMENT: |
| 689 | case POSITION: |
| 690 | case STATEMENT_POSITION: |
| 691 | case EXTERNAL_REFERENCE: |
| 692 | case INTERNAL_REFERENCE: |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 693 | case DEBUG_BREAK_SLOT: |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 694 | case NONE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 695 | break; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 696 | case NUMBER_OF_MODES: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 697 | UNREACHABLE(); |
| 698 | break; |
| 699 | } |
| 700 | } |
| 701 | #endif // DEBUG |
| 702 | |
| 703 | |
| 704 | // ----------------------------------------------------------------------------- |
| 705 | // Implementation of ExternalReference |
| 706 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 707 | ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate) |
| 708 | : address_(Redirect(isolate, Builtins::c_function_address(id))) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 709 | |
| 710 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 711 | ExternalReference::ExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 712 | ApiFunction* fun, |
| 713 | Type type = ExternalReference::BUILTIN_CALL, |
| 714 | Isolate* isolate = NULL) |
| 715 | : address_(Redirect(isolate, fun->address(), type)) {} |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 716 | |
| 717 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 718 | ExternalReference::ExternalReference(Builtins::Name name, Isolate* isolate) |
| 719 | : address_(isolate->builtins()->builtin_address(name)) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 720 | |
| 721 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 722 | ExternalReference::ExternalReference(Runtime::FunctionId id, |
| 723 | Isolate* isolate) |
| 724 | : address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 725 | |
| 726 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 727 | ExternalReference::ExternalReference(const Runtime::Function* f, |
| 728 | Isolate* isolate) |
| 729 | : address_(Redirect(isolate, f->entry)) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 730 | |
| 731 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 732 | ExternalReference ExternalReference::isolate_address() { |
| 733 | return ExternalReference(Isolate::Current()); |
| 734 | } |
| 735 | |
| 736 | |
| 737 | ExternalReference::ExternalReference(const IC_Utility& ic_utility, |
| 738 | Isolate* isolate) |
| 739 | : address_(Redirect(isolate, ic_utility.address())) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 740 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 741 | #ifdef ENABLE_DEBUGGER_SUPPORT |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 742 | ExternalReference::ExternalReference(const Debug_Address& debug_address, |
| 743 | Isolate* isolate) |
| 744 | : address_(debug_address.address(isolate)) {} |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 745 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 746 | |
| 747 | ExternalReference::ExternalReference(StatsCounter* counter) |
| 748 | : address_(reinterpret_cast<Address>(counter->GetInternalPointer())) {} |
| 749 | |
| 750 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 751 | ExternalReference::ExternalReference(Isolate::AddressId id, Isolate* isolate) |
| 752 | : address_(isolate->get_address_from_id(id)) {} |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 753 | |
| 754 | |
| 755 | ExternalReference::ExternalReference(const SCTableReference& table_ref) |
| 756 | : address_(table_ref.address()) {} |
| 757 | |
| 758 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 759 | ExternalReference ExternalReference:: |
| 760 | incremental_marking_record_write_function(Isolate* isolate) { |
| 761 | return ExternalReference(Redirect( |
| 762 | isolate, |
| 763 | FUNCTION_ADDR(IncrementalMarking::RecordWriteFromCode))); |
| 764 | } |
| 765 | |
| 766 | |
| 767 | ExternalReference ExternalReference:: |
| 768 | incremental_evacuation_record_write_function(Isolate* isolate) { |
| 769 | return ExternalReference(Redirect( |
| 770 | isolate, |
| 771 | FUNCTION_ADDR(IncrementalMarking::RecordWriteForEvacuationFromCode))); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | ExternalReference ExternalReference:: |
| 776 | store_buffer_overflow_function(Isolate* isolate) { |
| 777 | return ExternalReference(Redirect( |
| 778 | isolate, |
| 779 | FUNCTION_ADDR(StoreBuffer::StoreBufferOverflow))); |
| 780 | } |
| 781 | |
| 782 | |
| 783 | ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) { |
| 784 | return ExternalReference(Redirect(isolate, FUNCTION_ADDR(CPU::FlushICache))); |
| 785 | } |
| 786 | |
| 787 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 788 | ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 789 | return |
| 790 | ExternalReference(Redirect(isolate, FUNCTION_ADDR(Runtime::PerformGC))); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 794 | ExternalReference ExternalReference::fill_heap_number_with_random_function( |
| 795 | Isolate* isolate) { |
| 796 | return ExternalReference(Redirect( |
| 797 | isolate, |
| 798 | FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 802 | ExternalReference ExternalReference::delete_handle_scope_extensions( |
| 803 | Isolate* isolate) { |
| 804 | return ExternalReference(Redirect( |
| 805 | isolate, |
| 806 | FUNCTION_ADDR(HandleScope::DeleteExtensions))); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 810 | ExternalReference ExternalReference::random_uint32_function( |
| 811 | Isolate* isolate) { |
| 812 | return ExternalReference(Redirect(isolate, FUNCTION_ADDR(V8::Random))); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 816 | ExternalReference ExternalReference::transcendental_cache_array_address( |
| 817 | Isolate* isolate) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 818 | return ExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 819 | isolate->transcendental_cache()->cache_array_address()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 820 | } |
| 821 | |
| 822 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 823 | ExternalReference ExternalReference::new_deoptimizer_function( |
| 824 | Isolate* isolate) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 825 | return ExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 826 | Redirect(isolate, FUNCTION_ADDR(Deoptimizer::New))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 830 | ExternalReference ExternalReference::compute_output_frames_function( |
| 831 | Isolate* isolate) { |
| 832 | return ExternalReference( |
| 833 | Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 837 | ExternalReference ExternalReference::keyed_lookup_cache_keys(Isolate* isolate) { |
| 838 | return ExternalReference(isolate->keyed_lookup_cache()->keys_address()); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 842 | ExternalReference ExternalReference::keyed_lookup_cache_field_offsets( |
| 843 | Isolate* isolate) { |
| 844 | return ExternalReference( |
| 845 | isolate->keyed_lookup_cache()->field_offsets_address()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 849 | ExternalReference ExternalReference::roots_array_start(Isolate* isolate) { |
| 850 | return ExternalReference(isolate->heap()->roots_array_start()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 854 | ExternalReference ExternalReference::address_of_stack_limit(Isolate* isolate) { |
| 855 | return ExternalReference(isolate->stack_guard()->address_of_jslimit()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 859 | ExternalReference ExternalReference::address_of_real_stack_limit( |
| 860 | Isolate* isolate) { |
| 861 | return ExternalReference(isolate->stack_guard()->address_of_real_jslimit()); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 865 | ExternalReference ExternalReference::address_of_regexp_stack_limit( |
| 866 | Isolate* isolate) { |
| 867 | return ExternalReference(isolate->regexp_stack()->limit_address()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 868 | } |
| 869 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 870 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 871 | ExternalReference ExternalReference::new_space_start(Isolate* isolate) { |
| 872 | return ExternalReference(isolate->heap()->NewSpaceStart()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 876 | ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) { |
| 877 | return ExternalReference(isolate->heap()->store_buffer()->TopAddress()); |
| 878 | } |
| 879 | |
| 880 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 881 | ExternalReference ExternalReference::new_space_mask(Isolate* isolate) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 882 | return ExternalReference(reinterpret_cast<Address>( |
| 883 | isolate->heap()->NewSpaceMask())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 884 | } |
| 885 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 886 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 887 | ExternalReference ExternalReference::new_space_allocation_top_address( |
| 888 | Isolate* isolate) { |
| 889 | return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress()); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 890 | } |
| 891 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 892 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 893 | ExternalReference ExternalReference::heap_always_allocate_scope_depth( |
| 894 | Isolate* isolate) { |
| 895 | Heap* heap = isolate->heap(); |
| 896 | return ExternalReference(heap->always_allocate_scope_depth_address()); |
| 897 | } |
| 898 | |
| 899 | |
| 900 | ExternalReference ExternalReference::new_space_allocation_limit_address( |
| 901 | Isolate* isolate) { |
| 902 | return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 903 | } |
| 904 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 905 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 906 | ExternalReference ExternalReference::handle_scope_level_address() { |
| 907 | return ExternalReference(HandleScope::current_level_address()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | |
| 911 | ExternalReference ExternalReference::handle_scope_next_address() { |
| 912 | return ExternalReference(HandleScope::current_next_address()); |
| 913 | } |
| 914 | |
| 915 | |
| 916 | ExternalReference ExternalReference::handle_scope_limit_address() { |
| 917 | return ExternalReference(HandleScope::current_limit_address()); |
| 918 | } |
| 919 | |
| 920 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 921 | ExternalReference ExternalReference::scheduled_exception_address( |
| 922 | Isolate* isolate) { |
| 923 | return ExternalReference(isolate->scheduled_exception_address()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 927 | ExternalReference ExternalReference::address_of_min_int() { |
| 928 | return ExternalReference(reinterpret_cast<void*>( |
| 929 | const_cast<double*>(&DoubleConstant::min_int))); |
| 930 | } |
| 931 | |
| 932 | |
| 933 | ExternalReference ExternalReference::address_of_one_half() { |
| 934 | return ExternalReference(reinterpret_cast<void*>( |
| 935 | const_cast<double*>(&DoubleConstant::one_half))); |
| 936 | } |
| 937 | |
| 938 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 939 | ExternalReference ExternalReference::address_of_minus_zero() { |
| 940 | return ExternalReference(reinterpret_cast<void*>( |
| 941 | const_cast<double*>(&DoubleConstant::minus_zero))); |
| 942 | } |
| 943 | |
| 944 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 945 | ExternalReference ExternalReference::address_of_zero() { |
| 946 | return ExternalReference(reinterpret_cast<void*>( |
| 947 | const_cast<double*>(&DoubleConstant::zero))); |
| 948 | } |
| 949 | |
| 950 | |
| 951 | ExternalReference ExternalReference::address_of_uint8_max_value() { |
| 952 | return ExternalReference(reinterpret_cast<void*>( |
| 953 | const_cast<double*>(&DoubleConstant::uint8_max_value))); |
| 954 | } |
| 955 | |
| 956 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 957 | ExternalReference ExternalReference::address_of_negative_infinity() { |
| 958 | return ExternalReference(reinterpret_cast<void*>( |
| 959 | const_cast<double*>(&DoubleConstant::negative_infinity))); |
| 960 | } |
| 961 | |
| 962 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 963 | ExternalReference ExternalReference::address_of_canonical_non_hole_nan() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 964 | return ExternalReference(reinterpret_cast<void*>( |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 965 | const_cast<double*>(&DoubleConstant::canonical_non_hole_nan))); |
| 966 | } |
| 967 | |
| 968 | |
| 969 | ExternalReference ExternalReference::address_of_the_hole_nan() { |
| 970 | return ExternalReference(reinterpret_cast<void*>( |
| 971 | const_cast<double*>(&DoubleConstant::the_hole_nan))); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 975 | #ifndef V8_INTERPRETED_REGEXP |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 976 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 977 | ExternalReference ExternalReference::re_check_stack_guard_state( |
| 978 | Isolate* isolate) { |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 979 | Address function; |
| 980 | #ifdef V8_TARGET_ARCH_X64 |
| 981 | function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); |
| 982 | #elif V8_TARGET_ARCH_IA32 |
| 983 | function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); |
| 984 | #elif V8_TARGET_ARCH_ARM |
| 985 | function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 986 | #elif V8_TARGET_ARCH_MIPS |
| 987 | function = FUNCTION_ADDR(RegExpMacroAssemblerMIPS::CheckStackGuardState); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 988 | #else |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 989 | UNREACHABLE(); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 990 | #endif |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 991 | return ExternalReference(Redirect(isolate, function)); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 992 | } |
| 993 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 994 | ExternalReference ExternalReference::re_grow_stack(Isolate* isolate) { |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 995 | return ExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 996 | Redirect(isolate, FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack))); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 997 | } |
| 998 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 999 | ExternalReference ExternalReference::re_case_insensitive_compare_uc16( |
| 1000 | Isolate* isolate) { |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 1001 | return ExternalReference(Redirect( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1002 | isolate, |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 1003 | FUNCTION_ADDR(NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16))); |
| 1004 | } |
| 1005 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1006 | ExternalReference ExternalReference::re_word_character_map() { |
| 1007 | return ExternalReference( |
| 1008 | NativeRegExpMacroAssembler::word_character_map_address()); |
| 1009 | } |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1010 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1011 | ExternalReference ExternalReference::address_of_static_offsets_vector( |
| 1012 | Isolate* isolate) { |
| 1013 | return ExternalReference( |
| 1014 | OffsetsVector::static_offsets_vector_address(isolate)); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1017 | ExternalReference ExternalReference::address_of_regexp_stack_memory_address( |
| 1018 | Isolate* isolate) { |
| 1019 | return ExternalReference( |
| 1020 | isolate->regexp_stack()->memory_address()); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1023 | ExternalReference ExternalReference::address_of_regexp_stack_memory_size( |
| 1024 | Isolate* isolate) { |
| 1025 | return ExternalReference(isolate->regexp_stack()->memory_size_address()); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1026 | } |
| 1027 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 1028 | #endif // V8_INTERPRETED_REGEXP |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 1029 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1030 | |
| 1031 | static double add_two_doubles(double x, double y) { |
| 1032 | return x + y; |
| 1033 | } |
| 1034 | |
| 1035 | |
| 1036 | static double sub_two_doubles(double x, double y) { |
| 1037 | return x - y; |
| 1038 | } |
| 1039 | |
| 1040 | |
| 1041 | static double mul_two_doubles(double x, double y) { |
| 1042 | return x * y; |
| 1043 | } |
| 1044 | |
| 1045 | |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 1046 | static double div_two_doubles(double x, double y) { |
| 1047 | return x / y; |
| 1048 | } |
| 1049 | |
| 1050 | |
| 1051 | static double mod_two_doubles(double x, double y) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1052 | return modulo(x, y); |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1056 | static double math_sin_double(double x) { |
| 1057 | return sin(x); |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | static double math_cos_double(double x) { |
| 1062 | return cos(x); |
| 1063 | } |
| 1064 | |
| 1065 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1066 | static double math_tan_double(double x) { |
| 1067 | return tan(x); |
| 1068 | } |
| 1069 | |
| 1070 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1071 | static double math_log_double(double x) { |
| 1072 | return log(x); |
| 1073 | } |
| 1074 | |
| 1075 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1076 | ExternalReference ExternalReference::math_sin_double_function( |
| 1077 | Isolate* isolate) { |
| 1078 | return ExternalReference(Redirect(isolate, |
| 1079 | FUNCTION_ADDR(math_sin_double), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1080 | BUILTIN_FP_CALL)); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1084 | ExternalReference ExternalReference::math_cos_double_function( |
| 1085 | Isolate* isolate) { |
| 1086 | return ExternalReference(Redirect(isolate, |
| 1087 | FUNCTION_ADDR(math_cos_double), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1088 | BUILTIN_FP_CALL)); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1092 | ExternalReference ExternalReference::math_tan_double_function( |
| 1093 | Isolate* isolate) { |
| 1094 | return ExternalReference(Redirect(isolate, |
| 1095 | FUNCTION_ADDR(math_tan_double), |
| 1096 | BUILTIN_FP_CALL)); |
| 1097 | } |
| 1098 | |
| 1099 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1100 | ExternalReference ExternalReference::math_log_double_function( |
| 1101 | Isolate* isolate) { |
| 1102 | return ExternalReference(Redirect(isolate, |
| 1103 | FUNCTION_ADDR(math_log_double), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1104 | BUILTIN_FP_CALL)); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1108 | // Helper function to compute x^y, where y is known to be an |
| 1109 | // integer. Uses binary decomposition to limit the number of |
| 1110 | // multiplications; see the discussion in "Hacker's Delight" by Henry |
| 1111 | // S. Warren, Jr., figure 11-6, page 213. |
| 1112 | double power_double_int(double x, int y) { |
| 1113 | double m = (y < 0) ? 1 / x : x; |
| 1114 | unsigned n = (y < 0) ? -y : y; |
| 1115 | double p = 1; |
| 1116 | while (n != 0) { |
| 1117 | if ((n & 1) != 0) p *= m; |
| 1118 | m *= m; |
| 1119 | if ((n & 2) != 0) p *= m; |
| 1120 | m *= m; |
| 1121 | n >>= 2; |
| 1122 | } |
| 1123 | return p; |
| 1124 | } |
| 1125 | |
| 1126 | |
| 1127 | double power_double_double(double x, double y) { |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1128 | // The checks for special cases can be dropped in ia32 because it has already |
| 1129 | // been done in generated code before bailing out here. |
| 1130 | if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) return OS::nan_value(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1131 | return pow(x, y); |
| 1132 | } |
| 1133 | |
| 1134 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1135 | ExternalReference ExternalReference::power_double_double_function( |
| 1136 | Isolate* isolate) { |
| 1137 | return ExternalReference(Redirect(isolate, |
| 1138 | FUNCTION_ADDR(power_double_double), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1139 | BUILTIN_FP_FP_CALL)); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1143 | ExternalReference ExternalReference::power_double_int_function( |
| 1144 | Isolate* isolate) { |
| 1145 | return ExternalReference(Redirect(isolate, |
| 1146 | FUNCTION_ADDR(power_double_int), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1147 | BUILTIN_FP_INT_CALL)); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1151 | static int native_compare_doubles(double y, double x) { |
| 1152 | if (x == y) return EQUAL; |
| 1153 | return x < y ? LESS : GREATER; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1157 | bool EvalComparison(Token::Value op, double op1, double op2) { |
| 1158 | ASSERT(Token::IsCompareOp(op)); |
| 1159 | switch (op) { |
| 1160 | case Token::EQ: |
| 1161 | case Token::EQ_STRICT: return (op1 == op2); |
| 1162 | case Token::NE: return (op1 != op2); |
| 1163 | case Token::LT: return (op1 < op2); |
| 1164 | case Token::GT: return (op1 > op2); |
| 1165 | case Token::LTE: return (op1 <= op2); |
| 1166 | case Token::GTE: return (op1 >= op2); |
| 1167 | default: |
| 1168 | UNREACHABLE(); |
| 1169 | return false; |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1174 | ExternalReference ExternalReference::double_fp_operation( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1175 | Token::Value operation, Isolate* isolate) { |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1176 | typedef double BinaryFPOperation(double x, double y); |
| 1177 | BinaryFPOperation* function = NULL; |
| 1178 | switch (operation) { |
| 1179 | case Token::ADD: |
| 1180 | function = &add_two_doubles; |
| 1181 | break; |
| 1182 | case Token::SUB: |
| 1183 | function = &sub_two_doubles; |
| 1184 | break; |
| 1185 | case Token::MUL: |
| 1186 | function = &mul_two_doubles; |
| 1187 | break; |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 1188 | case Token::DIV: |
| 1189 | function = &div_two_doubles; |
| 1190 | break; |
| 1191 | case Token::MOD: |
| 1192 | function = &mod_two_doubles; |
| 1193 | break; |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1194 | default: |
| 1195 | UNREACHABLE(); |
| 1196 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1197 | return ExternalReference(Redirect(isolate, |
| 1198 | FUNCTION_ADDR(function), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1199 | BUILTIN_FP_FP_CALL)); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1200 | } |
| 1201 | |
| 1202 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1203 | ExternalReference ExternalReference::compare_doubles(Isolate* isolate) { |
| 1204 | return ExternalReference(Redirect(isolate, |
| 1205 | FUNCTION_ADDR(native_compare_doubles), |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1206 | BUILTIN_COMPARE_CALL)); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1210 | #ifdef ENABLE_DEBUGGER_SUPPORT |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1211 | ExternalReference ExternalReference::debug_break(Isolate* isolate) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 1212 | return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug_Break))); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1216 | ExternalReference ExternalReference::debug_step_in_fp_address( |
| 1217 | Isolate* isolate) { |
| 1218 | return ExternalReference(isolate->debug()->step_in_fp_addr()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1219 | } |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1220 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1221 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1222 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1223 | void PositionsRecorder::RecordPosition(int pos) { |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1224 | ASSERT(pos != RelocInfo::kNoPosition); |
| 1225 | ASSERT(pos >= 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1226 | state_.current_position = pos; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1227 | #ifdef ENABLE_GDB_JIT_INTERFACE |
| 1228 | if (gdbjit_lineinfo_ != NULL) { |
| 1229 | gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, false); |
| 1230 | } |
| 1231 | #endif |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | |
| 1235 | void PositionsRecorder::RecordStatementPosition(int pos) { |
| 1236 | ASSERT(pos != RelocInfo::kNoPosition); |
| 1237 | ASSERT(pos >= 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1238 | state_.current_statement_position = pos; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1239 | #ifdef ENABLE_GDB_JIT_INTERFACE |
| 1240 | if (gdbjit_lineinfo_ != NULL) { |
| 1241 | gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, true); |
| 1242 | } |
| 1243 | #endif |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | |
| 1247 | bool PositionsRecorder::WriteRecordedPositions() { |
| 1248 | bool written = false; |
| 1249 | |
| 1250 | // Write the statement position if it is different from what was written last |
| 1251 | // time. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1252 | if (state_.current_statement_position != state_.written_statement_position) { |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1253 | EnsureSpace ensure_space(assembler_); |
| 1254 | assembler_->RecordRelocInfo(RelocInfo::STATEMENT_POSITION, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1255 | state_.current_statement_position); |
| 1256 | state_.written_statement_position = state_.current_statement_position; |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1257 | written = true; |
| 1258 | } |
| 1259 | |
| 1260 | // Write the position if it is different from what was written last time and |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1261 | // also different from the written statement position. |
| 1262 | if (state_.current_position != state_.written_position && |
| 1263 | state_.current_position != state_.written_statement_position) { |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1264 | EnsureSpace ensure_space(assembler_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1265 | assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
| 1266 | state_.written_position = state_.current_position; |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1267 | written = true; |
| 1268 | } |
| 1269 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1270 | // Return whether something was written. |
| 1271 | return written; |
| 1272 | } |
| 1273 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1274 | } } // namespace v8::internal |