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