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