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