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