2011-12-20 10:57:12 +00:00
|
|
|
// Copyright (c) 1994-2006 Sun Microsystems Inc.
|
2008-07-03 15:10:15 +00:00
|
|
|
// All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// - Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// - Redistribution in binary form must reproduce the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer in the
|
|
|
|
// documentation and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// - Neither the name of Sun Microsystems or the names of contributors may
|
|
|
|
// be used to endorse or promote products derived from this software without
|
|
|
|
// specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
|
|
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
// The original source code covered by the above license above has been
|
|
|
|
// modified significantly by Google Inc.
|
2011-04-27 15:02:59 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#include "arguments.h"
|
2010-12-07 11:31:57 +00:00
|
|
|
#include "deoptimizer.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "execution.h"
|
|
|
|
#include "ic-inl.h"
|
2011-09-19 18:36:47 +00:00
|
|
|
#include "incremental-marking.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "factory.h"
|
|
|
|
#include "runtime.h"
|
2010-12-07 11:31:57 +00:00
|
|
|
#include "runtime-profiler.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "serialize.h"
|
|
|
|
#include "stub-cache.h"
|
2009-01-12 13:05:23 +00:00
|
|
|
#include "regexp-stack.h"
|
2009-08-31 12:40:37 +00:00
|
|
|
#include "ast.h"
|
|
|
|
#include "regexp-macro-assembler.h"
|
2010-01-18 08:36:06 +00:00
|
|
|
#include "platform.h"
|
2011-09-19 18:36:47 +00:00
|
|
|
#include "store-buffer.h"
|
2009-08-31 12:40:37 +00:00
|
|
|
// Include native regexp-macro-assembler.
|
2010-04-19 19:30:11 +00:00
|
|
|
#ifndef V8_INTERPRETED_REGEXP
|
2009-08-31 12:40:37 +00:00
|
|
|
#if V8_TARGET_ARCH_IA32
|
|
|
|
#include "ia32/regexp-macro-assembler-ia32.h"
|
|
|
|
#elif V8_TARGET_ARCH_X64
|
|
|
|
#include "x64/regexp-macro-assembler-x64.h"
|
|
|
|
#elif V8_TARGET_ARCH_ARM
|
|
|
|
#include "arm/regexp-macro-assembler-arm.h"
|
2011-03-28 13:05:36 +00:00
|
|
|
#elif V8_TARGET_ARCH_MIPS
|
|
|
|
#include "mips/regexp-macro-assembler-mips.h"
|
2009-08-31 12:40:37 +00:00
|
|
|
#else // Unknown architecture.
|
|
|
|
#error "Unknown architecture."
|
|
|
|
#endif // Target architecture.
|
2010-04-19 19:30:11 +00:00
|
|
|
#endif // V8_INTERPRETED_REGEXP
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
const double DoubleConstant::min_int = kMinInt;
|
|
|
|
const double DoubleConstant::one_half = 0.5;
|
2011-01-11 13:48:49 +00:00
|
|
|
const double DoubleConstant::minus_zero = -0.0;
|
2011-05-16 14:10:56 +00:00
|
|
|
const double DoubleConstant::uint8_max_value = 255;
|
|
|
|
const double DoubleConstant::zero = 0.0;
|
2011-07-13 16:36:26 +00:00
|
|
|
const double DoubleConstant::canonical_non_hole_nan = OS::nan_value();
|
2011-07-13 13:50:27 +00:00
|
|
|
const double DoubleConstant::the_hole_nan = BitCast<double>(kHoleNanInt64);
|
2010-12-08 14:32:40 +00:00
|
|
|
const double DoubleConstant::negative_infinity = -V8_INFINITY;
|
2011-08-05 11:32:46 +00:00
|
|
|
const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING";
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2011-05-11 14:16:24 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Implementation of AssemblerBase
|
|
|
|
|
|
|
|
AssemblerBase::AssemblerBase(Isolate* isolate)
|
|
|
|
: isolate_(isolate),
|
|
|
|
jit_cookie_(0) {
|
|
|
|
if (FLAG_mask_constants_with_cookie && isolate != NULL) {
|
|
|
|
jit_cookie_ = V8::RandomPrivate(isolate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Implementation of Label
|
|
|
|
|
|
|
|
int Label::pos() const {
|
|
|
|
if (pos_ < 0) return -pos_ - 1;
|
|
|
|
if (pos_ > 0) return pos_ - 1;
|
|
|
|
UNREACHABLE();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Implementation of RelocInfoWriter and RelocIterator
|
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// Relocation information is written backwards in memory, from high addresses
|
|
|
|
// towards low addresses, byte by byte. Therefore, in the encodings listed
|
|
|
|
// below, the first byte listed it at the highest address, and successive
|
|
|
|
// bytes in the record are at progressively lower addresses.
|
|
|
|
//
|
2008-07-03 15:10:15 +00:00
|
|
|
// Encoding
|
|
|
|
//
|
|
|
|
// The most common modes are given single-byte encodings. Also, it is
|
|
|
|
// easy to identify the type of reloc info and skip unwanted modes in
|
|
|
|
// an iteration.
|
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// The encoding relies on the fact that there are fewer than 14
|
|
|
|
// different non-compactly encoded relocation modes.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// The first byte of a relocation record has a tag in its low 2 bits:
|
|
|
|
// Here are the record schemes, depending on the low tag and optional higher
|
|
|
|
// tags.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// Low tag:
|
|
|
|
// 00: embedded_object: [6-bit pc delta] 00
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 01: code_target: [6-bit pc delta] 01
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 10: short_data_record: [6-bit pc delta] 10 followed by
|
|
|
|
// [6-bit data delta] [2-bit data type tag]
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 11: long_record [2-bit high tag][4 bit middle_tag] 11
|
|
|
|
// followed by variable data depending on type.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 2-bit data type tags, used in short_data_record and data_jump long_record:
|
|
|
|
// code_target_with_id: 00
|
|
|
|
// position: 01
|
|
|
|
// statement_position: 10
|
|
|
|
// comment: 11 (not used in short_data_record)
|
2011-04-19 16:04:49 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// Long record format:
|
|
|
|
// 4-bit middle_tag:
|
|
|
|
// 0000 - 1100 : Short record for RelocInfo::Mode middle_tag + 2
|
|
|
|
// (The middle_tag encodes rmode - RelocInfo::LAST_COMPACT_ENUM,
|
|
|
|
// and is between 0000 and 1100)
|
|
|
|
// The format is:
|
|
|
|
// 00 [4 bit middle_tag] 11 followed by
|
|
|
|
// 00 [6 bit pc delta]
|
2011-04-19 16:04:49 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 1101: not used (would allow one more relocation mode to be added)
|
|
|
|
// 1110: long_data_record
|
|
|
|
// The format is: [2-bit data_type_tag] 1110 11
|
|
|
|
// signed intptr_t, lowest byte written first
|
|
|
|
// (except data_type code_target_with_id, which
|
|
|
|
// is followed by a signed int, not intptr_t.)
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2011-04-27 15:02:59 +00:00
|
|
|
// 1111: long_pc_jump
|
|
|
|
// The format is:
|
|
|
|
// pc-jump: 00 1111 11,
|
|
|
|
// 00 [6 bits pc delta]
|
|
|
|
// or
|
|
|
|
// pc-jump (variable length):
|
|
|
|
// 01 1111 11,
|
|
|
|
// [7 bits data] 0
|
|
|
|
// ...
|
|
|
|
// [7 bits data] 1
|
|
|
|
// (Bits 6..31 of pc delta, with leading zeroes
|
|
|
|
// dropped, and last non-zero chunk tagged with 1.)
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
const int kMaxRelocModes = 14;
|
|
|
|
|
|
|
|
const int kTagBits = 2;
|
|
|
|
const int kTagMask = (1 << kTagBits) - 1;
|
|
|
|
const int kExtraTagBits = 4;
|
2011-04-27 15:02:59 +00:00
|
|
|
const int kLocatableTypeTagBits = 2;
|
|
|
|
const int kSmallDataBits = kBitsPerByte - kLocatableTypeTagBits;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
const int kEmbeddedObjectTag = 0;
|
|
|
|
const int kCodeTargetTag = 1;
|
2011-04-27 15:02:59 +00:00
|
|
|
const int kLocatableTag = 2;
|
2008-07-03 15:10:15 +00:00
|
|
|
const int kDefaultTag = 3;
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
const int kPCJumpExtraTag = (1 << kExtraTagBits) - 1;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
const int kSmallPCDeltaBits = kBitsPerByte - kTagBits;
|
|
|
|
const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1;
|
2011-03-25 10:29:34 +00:00
|
|
|
const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
const int kVariableLengthPCJumpTopTag = 1;
|
|
|
|
const int kChunkBits = 7;
|
|
|
|
const int kChunkMask = (1 << kChunkBits) - 1;
|
|
|
|
const int kLastChunkTagBits = 1;
|
|
|
|
const int kLastChunkTagMask = 1;
|
|
|
|
const int kLastChunkTag = 1;
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
const int kDataJumpExtraTag = kPCJumpExtraTag - 1;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
const int kCodeWithIdTag = 0;
|
|
|
|
const int kNonstatementPositionTag = 1;
|
|
|
|
const int kStatementPositionTag = 2;
|
|
|
|
const int kCommentTag = 3;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
uint32_t RelocInfoWriter::WriteVariableLengthPCJump(uint32_t pc_delta) {
|
|
|
|
// Return if the pc_delta can fit in kSmallPCDeltaBits bits.
|
|
|
|
// Otherwise write a variable length PC jump for the bits that do
|
|
|
|
// not fit in the kSmallPCDeltaBits bits.
|
|
|
|
if (is_uintn(pc_delta, kSmallPCDeltaBits)) return pc_delta;
|
2011-04-27 15:02:59 +00:00
|
|
|
WriteExtraTag(kPCJumpExtraTag, kVariableLengthPCJumpTopTag);
|
2008-07-03 15:10:15 +00:00
|
|
|
uint32_t pc_jump = pc_delta >> kSmallPCDeltaBits;
|
|
|
|
ASSERT(pc_jump > 0);
|
|
|
|
// Write kChunkBits size chunks of the pc_jump.
|
|
|
|
for (; pc_jump > 0; pc_jump = pc_jump >> kChunkBits) {
|
|
|
|
byte b = pc_jump & kChunkMask;
|
|
|
|
*--pos_ = b << kLastChunkTagBits;
|
|
|
|
}
|
|
|
|
// Tag the last chunk so it can be identified.
|
|
|
|
*pos_ = *pos_ | kLastChunkTag;
|
|
|
|
// Return the remaining kSmallPCDeltaBits of the pc_delta.
|
|
|
|
return pc_delta & kSmallPCDeltaMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocInfoWriter::WriteTaggedPC(uint32_t pc_delta, int tag) {
|
|
|
|
// Write a byte of tagged pc-delta, possibly preceded by var. length pc-jump.
|
|
|
|
pc_delta = WriteVariableLengthPCJump(pc_delta);
|
|
|
|
*--pos_ = pc_delta << kTagBits | tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-29 12:14:54 +00:00
|
|
|
void RelocInfoWriter::WriteTaggedData(intptr_t data_delta, int tag) {
|
2011-04-27 15:02:59 +00:00
|
|
|
*--pos_ = static_cast<byte>(data_delta << kLocatableTypeTagBits | tag);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocInfoWriter::WriteExtraTag(int extra_tag, int top_tag) {
|
2009-11-11 09:50:06 +00:00
|
|
|
*--pos_ = static_cast<int>(top_tag << (kTagBits + kExtraTagBits) |
|
|
|
|
extra_tag << kTagBits |
|
|
|
|
kDefaultTag);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) {
|
|
|
|
// Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump.
|
|
|
|
pc_delta = WriteVariableLengthPCJump(pc_delta);
|
|
|
|
WriteExtraTag(extra_tag, 0);
|
|
|
|
*--pos_ = pc_delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
void RelocInfoWriter::WriteExtraTaggedIntData(int data_delta, int top_tag) {
|
|
|
|
WriteExtraTag(kDataJumpExtraTag, top_tag);
|
|
|
|
for (int i = 0; i < kIntSize; i++) {
|
|
|
|
*--pos_ = static_cast<byte>(data_delta);
|
|
|
|
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
|
|
|
|
data_delta = data_delta >> kBitsPerByte;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-29 12:14:54 +00:00
|
|
|
void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) {
|
2011-04-27 15:02:59 +00:00
|
|
|
WriteExtraTag(kDataJumpExtraTag, top_tag);
|
2009-05-29 12:14:54 +00:00
|
|
|
for (int i = 0; i < kIntptrSize; i++) {
|
2009-11-11 09:50:06 +00:00
|
|
|
*--pos_ = static_cast<byte>(data_delta);
|
2011-04-27 15:02:59 +00:00
|
|
|
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
|
2009-05-29 12:14:54 +00:00
|
|
|
data_delta = data_delta >> kBitsPerByte;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocInfoWriter::Write(const RelocInfo* rinfo) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
byte* begin_pos = pos_;
|
|
|
|
#endif
|
|
|
|
ASSERT(rinfo->pc() - last_pc_ >= 0);
|
2011-04-27 15:02:59 +00:00
|
|
|
ASSERT(RelocInfo::NUMBER_OF_MODES - RelocInfo::LAST_COMPACT_ENUM <=
|
|
|
|
kMaxRelocModes);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Use unsigned delta-encoding for pc.
|
2009-11-11 09:50:06 +00:00
|
|
|
uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_);
|
2008-09-22 13:57:03 +00:00
|
|
|
RelocInfo::Mode rmode = rinfo->rmode();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// The two most common modes are given small tags, and usually fit in a byte.
|
2008-09-22 13:57:03 +00:00
|
|
|
if (rmode == RelocInfo::EMBEDDED_OBJECT) {
|
2008-07-03 15:10:15 +00:00
|
|
|
WriteTaggedPC(pc_delta, kEmbeddedObjectTag);
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (rmode == RelocInfo::CODE_TARGET) {
|
2008-07-03 15:10:15 +00:00
|
|
|
WriteTaggedPC(pc_delta, kCodeTargetTag);
|
2011-02-22 12:28:33 +00:00
|
|
|
ASSERT(begin_pos - pos_ <= RelocInfo::kMaxCallSize);
|
2011-04-27 15:02:59 +00:00
|
|
|
} else if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
|
|
|
|
// Use signed delta-encoding for id.
|
|
|
|
ASSERT(static_cast<int>(rinfo->data()) == rinfo->data());
|
|
|
|
int id_delta = static_cast<int>(rinfo->data()) - last_id_;
|
|
|
|
// Check if delta is small enough to fit in a tagged byte.
|
|
|
|
if (is_intn(id_delta, kSmallDataBits)) {
|
|
|
|
WriteTaggedPC(pc_delta, kLocatableTag);
|
|
|
|
WriteTaggedData(id_delta, kCodeWithIdTag);
|
|
|
|
} else {
|
|
|
|
// Otherwise, use costly encoding.
|
|
|
|
WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag);
|
|
|
|
WriteExtraTaggedIntData(id_delta, kCodeWithIdTag);
|
|
|
|
}
|
|
|
|
last_id_ = static_cast<int>(rinfo->data());
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (RelocInfo::IsPosition(rmode)) {
|
2011-04-27 15:02:59 +00:00
|
|
|
// Use signed delta-encoding for position.
|
|
|
|
ASSERT(static_cast<int>(rinfo->data()) == rinfo->data());
|
|
|
|
int pos_delta = static_cast<int>(rinfo->data()) - last_position_;
|
|
|
|
int pos_type_tag = (rmode == RelocInfo::POSITION) ? kNonstatementPositionTag
|
|
|
|
: kStatementPositionTag;
|
|
|
|
// Check if delta is small enough to fit in a tagged byte.
|
|
|
|
if (is_intn(pos_delta, kSmallDataBits)) {
|
|
|
|
WriteTaggedPC(pc_delta, kLocatableTag);
|
|
|
|
WriteTaggedData(pos_delta, pos_type_tag);
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
|
|
|
// Otherwise, use costly encoding.
|
2011-04-27 15:02:59 +00:00
|
|
|
WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag);
|
|
|
|
WriteExtraTaggedIntData(pos_delta, pos_type_tag);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-04-27 15:02:59 +00:00
|
|
|
last_position_ = static_cast<int>(rinfo->data());
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (RelocInfo::IsComment(rmode)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
// Comments are normally not generated, so we use the costly encoding.
|
2011-04-27 15:02:59 +00:00
|
|
|
WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag);
|
|
|
|
WriteExtraTaggedData(rinfo->data(), kCommentTag);
|
2011-02-24 10:29:01 +00:00
|
|
|
ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize);
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
2011-04-27 15:02:59 +00:00
|
|
|
ASSERT(rmode > RelocInfo::LAST_COMPACT_ENUM);
|
|
|
|
int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM;
|
2008-07-03 15:10:15 +00:00
|
|
|
// For all other modes we simply use the mode as the extra tag.
|
|
|
|
// None of these modes need a data component.
|
2011-04-27 15:02:59 +00:00
|
|
|
ASSERT(saved_mode < kPCJumpExtraTag && saved_mode < kDataJumpExtraTag);
|
|
|
|
WriteExtraTaggedPC(pc_delta, saved_mode);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
last_pc_ = rinfo->pc();
|
|
|
|
#ifdef DEBUG
|
|
|
|
ASSERT(begin_pos - pos_ <= kMaxSize);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline int RelocIterator::AdvanceGetTag() {
|
|
|
|
return *--pos_ & kTagMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline int RelocIterator::GetExtraTag() {
|
|
|
|
return (*pos_ >> kTagBits) & ((1 << kExtraTagBits) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline int RelocIterator::GetTopTag() {
|
|
|
|
return *pos_ >> (kTagBits + kExtraTagBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RelocIterator::ReadTaggedPC() {
|
|
|
|
rinfo_.pc_ += *pos_ >> kTagBits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void RelocIterator::AdvanceReadPC() {
|
|
|
|
rinfo_.pc_ += *--pos_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
void RelocIterator::AdvanceReadId() {
|
|
|
|
int x = 0;
|
|
|
|
for (int i = 0; i < kIntSize; i++) {
|
|
|
|
x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
|
|
|
|
}
|
|
|
|
last_id_ += x;
|
|
|
|
rinfo_.data_ = last_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocIterator::AdvanceReadPosition() {
|
|
|
|
int x = 0;
|
|
|
|
for (int i = 0; i < kIntSize; i++) {
|
|
|
|
x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
|
|
|
|
}
|
|
|
|
last_position_ += x;
|
|
|
|
rinfo_.data_ = last_position_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void RelocIterator::AdvanceReadData() {
|
2009-05-29 12:14:54 +00:00
|
|
|
intptr_t x = 0;
|
|
|
|
for (int i = 0; i < kIntptrSize; i++) {
|
|
|
|
x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-04-27 15:02:59 +00:00
|
|
|
rinfo_.data_ = x;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocIterator::AdvanceReadVariableLengthPCJump() {
|
|
|
|
// Read the 32-kSmallPCDeltaBits most significant bits of the
|
|
|
|
// pc jump in kChunkBits bit chunks and shift them into place.
|
|
|
|
// Stop when the last chunk is encountered.
|
|
|
|
uint32_t pc_jump = 0;
|
|
|
|
for (int i = 0; i < kIntSize; i++) {
|
|
|
|
byte pc_jump_part = *--pos_;
|
|
|
|
pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits;
|
|
|
|
if ((pc_jump_part & kLastChunkTagMask) == 1) break;
|
|
|
|
}
|
|
|
|
// The least significant kSmallPCDeltaBits bits will be added
|
|
|
|
// later.
|
|
|
|
rinfo_.pc_ += pc_jump << kSmallPCDeltaBits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
inline int RelocIterator::GetLocatableTypeTag() {
|
|
|
|
return *pos_ & ((1 << kLocatableTypeTagBits) - 1);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
inline void RelocIterator::ReadTaggedId() {
|
2011-04-15 13:18:53 +00:00
|
|
|
int8_t signed_b = *pos_;
|
|
|
|
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
|
2011-04-27 15:02:59 +00:00
|
|
|
last_id_ += signed_b >> kLocatableTypeTagBits;
|
|
|
|
rinfo_.data_ = last_id_;
|
2011-04-15 13:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 15:02:59 +00:00
|
|
|
inline void RelocIterator::ReadTaggedPosition() {
|
|
|
|
int8_t signed_b = *pos_;
|
|
|
|
// Signed right shift is arithmetic shift. Tested in test-utils.cc.
|
|
|
|
last_position_ += signed_b >> kLocatableTypeTagBits;
|
|
|
|
rinfo_.data_ = last_position_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline RelocInfo::Mode GetPositionModeFromTag(int tag) {
|
|
|
|
ASSERT(tag == kNonstatementPositionTag ||
|
|
|
|
tag == kStatementPositionTag);
|
|
|
|
return (tag == kNonstatementPositionTag) ?
|
|
|
|
RelocInfo::POSITION :
|
|
|
|
RelocInfo::STATEMENT_POSITION;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RelocIterator::next() {
|
|
|
|
ASSERT(!done());
|
|
|
|
// Basically, do the opposite of RelocInfoWriter::Write.
|
|
|
|
// Reading of data is as far as possible avoided for unwanted modes,
|
|
|
|
// but we must always update the pc.
|
|
|
|
//
|
|
|
|
// We exit this loop by returning when we find a mode we want.
|
|
|
|
while (pos_ > end_) {
|
|
|
|
int tag = AdvanceGetTag();
|
|
|
|
if (tag == kEmbeddedObjectTag) {
|
|
|
|
ReadTaggedPC();
|
2008-09-22 13:57:03 +00:00
|
|
|
if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return;
|
2008-07-03 15:10:15 +00:00
|
|
|
} else if (tag == kCodeTargetTag) {
|
|
|
|
ReadTaggedPC();
|
2008-09-22 13:57:03 +00:00
|
|
|
if (SetMode(RelocInfo::CODE_TARGET)) return;
|
2011-04-27 15:02:59 +00:00
|
|
|
} else if (tag == kLocatableTag) {
|
2008-07-03 15:10:15 +00:00
|
|
|
ReadTaggedPC();
|
|
|
|
Advance();
|
2011-04-27 15:02:59 +00:00
|
|
|
int locatable_tag = GetLocatableTypeTag();
|
|
|
|
if (locatable_tag == kCodeWithIdTag) {
|
|
|
|
if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) {
|
|
|
|
ReadTaggedId();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Compact encoding is never used for comments,
|
|
|
|
// so it must be a position.
|
|
|
|
ASSERT(locatable_tag == kNonstatementPositionTag ||
|
|
|
|
locatable_tag == kStatementPositionTag);
|
|
|
|
if (mode_mask_ & RelocInfo::kPositionMask) {
|
|
|
|
ReadTaggedPosition();
|
|
|
|
if (SetMode(GetPositionModeFromTag(locatable_tag))) return;
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ASSERT(tag == kDefaultTag);
|
|
|
|
int extra_tag = GetExtraTag();
|
2011-04-27 15:02:59 +00:00
|
|
|
if (extra_tag == kPCJumpExtraTag) {
|
2008-07-03 15:10:15 +00:00
|
|
|
int top_tag = GetTopTag();
|
|
|
|
if (top_tag == kVariableLengthPCJumpTopTag) {
|
|
|
|
AdvanceReadVariableLengthPCJump();
|
|
|
|
} else {
|
|
|
|
AdvanceReadPC();
|
|
|
|
}
|
2011-04-27 15:02:59 +00:00
|
|
|
} else if (extra_tag == kDataJumpExtraTag) {
|
|
|
|
int locatable_tag = GetTopTag();
|
|
|
|
if (locatable_tag == kCodeWithIdTag) {
|
|
|
|
if (SetMode(RelocInfo::CODE_TARGET_WITH_ID)) {
|
|
|
|
AdvanceReadId();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Advance(kIntSize);
|
|
|
|
} else if (locatable_tag != kCommentTag) {
|
|
|
|
ASSERT(locatable_tag == kNonstatementPositionTag ||
|
|
|
|
locatable_tag == kStatementPositionTag);
|
|
|
|
if (mode_mask_ & RelocInfo::kPositionMask) {
|
|
|
|
AdvanceReadPosition();
|
|
|
|
if (SetMode(GetPositionModeFromTag(locatable_tag))) return;
|
|
|
|
} else {
|
|
|
|
Advance(kIntSize);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
2011-04-27 15:02:59 +00:00
|
|
|
ASSERT(locatable_tag == kCommentTag);
|
|
|
|
if (SetMode(RelocInfo::COMMENT)) {
|
|
|
|
AdvanceReadData();
|
|
|
|
return;
|
|
|
|
}
|
2009-06-11 10:46:28 +00:00
|
|
|
Advance(kIntptrSize);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AdvanceReadPC();
|
2011-04-27 15:02:59 +00:00
|
|
|
int rmode = extra_tag + RelocInfo::LAST_COMPACT_ENUM;
|
|
|
|
if (SetMode(static_cast<RelocInfo::Mode>(rmode))) return;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RelocIterator::RelocIterator(Code* code, int mode_mask) {
|
2011-09-19 18:36:47 +00:00
|
|
|
rinfo_.host_ = code;
|
2008-07-03 15:10:15 +00:00
|
|
|
rinfo_.pc_ = code->instruction_start();
|
|
|
|
rinfo_.data_ = 0;
|
2010-12-07 11:31:57 +00:00
|
|
|
// Relocation info is read backwards.
|
2008-07-03 15:10:15 +00:00
|
|
|
pos_ = code->relocation_start() + code->relocation_size();
|
|
|
|
end_ = code->relocation_start();
|
|
|
|
done_ = false;
|
|
|
|
mode_mask_ = mode_mask;
|
2011-04-27 15:02:59 +00:00
|
|
|
last_id_ = 0;
|
|
|
|
last_position_ = 0;
|
2008-07-03 15:10:15 +00:00
|
|
|
if (mode_mask_ == 0) pos_ = end_;
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) {
|
|
|
|
rinfo_.pc_ = desc.buffer;
|
|
|
|
rinfo_.data_ = 0;
|
2010-12-07 11:31:57 +00:00
|
|
|
// Relocation info is read backwards.
|
2008-07-03 15:10:15 +00:00
|
|
|
pos_ = desc.buffer + desc.buffer_size;
|
|
|
|
end_ = pos_ - desc.reloc_size;
|
|
|
|
done_ = false;
|
|
|
|
mode_mask_ = mode_mask;
|
2011-04-27 15:02:59 +00:00
|
|
|
last_id_ = 0;
|
|
|
|
last_position_ = 0;
|
2008-07-03 15:10:15 +00:00
|
|
|
if (mode_mask_ == 0) pos_ = end_;
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Implementation of RelocInfo
|
|
|
|
|
|
|
|
|
2008-08-06 10:02:49 +00:00
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
2008-09-22 13:57:03 +00:00
|
|
|
const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
|
2008-07-03 15:10:15 +00:00
|
|
|
switch (rmode) {
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::NONE:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "no reloc";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::EMBEDDED_OBJECT:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "embedded object";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::CONSTRUCT_CALL:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "code target (js construct call)";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::CODE_TARGET_CONTEXT:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "code target (context)";
|
2010-02-08 13:44:49 +00:00
|
|
|
case RelocInfo::DEBUG_BREAK:
|
|
|
|
#ifndef ENABLE_DEBUGGER_SUPPORT
|
|
|
|
UNREACHABLE();
|
|
|
|
#endif
|
|
|
|
return "debug break";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::CODE_TARGET:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "code target";
|
2011-04-27 15:02:59 +00:00
|
|
|
case RelocInfo::CODE_TARGET_WITH_ID:
|
|
|
|
return "code target with id";
|
2010-12-07 11:31:57 +00:00
|
|
|
case RelocInfo::GLOBAL_PROPERTY_CELL:
|
|
|
|
return "global property cell";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::RUNTIME_ENTRY:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "runtime entry";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::JS_RETURN:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "js return";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::COMMENT:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "comment";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::POSITION:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "position";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::STATEMENT_POSITION:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "statement position";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::EXTERNAL_REFERENCE:
|
2008-07-03 15:10:15 +00:00
|
|
|
return "external reference";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::INTERNAL_REFERENCE:
|
2008-09-18 11:59:55 +00:00
|
|
|
return "internal reference";
|
2010-06-08 12:04:49 +00:00
|
|
|
case RelocInfo::DEBUG_BREAK_SLOT:
|
|
|
|
#ifndef ENABLE_DEBUGGER_SUPPORT
|
|
|
|
UNREACHABLE();
|
|
|
|
#endif
|
|
|
|
return "debug break slot";
|
2008-09-22 13:57:03 +00:00
|
|
|
case RelocInfo::NUMBER_OF_MODES:
|
2008-07-03 15:10:15 +00:00
|
|
|
UNREACHABLE();
|
2008-09-22 13:57:03 +00:00
|
|
|
return "number_of_modes";
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
return "unknown relocation type";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-20 10:38:19 +00:00
|
|
|
void RelocInfo::Print(FILE* out) {
|
|
|
|
PrintF(out, "%p %s", pc_, RelocModeName(rmode_));
|
2008-09-22 13:57:03 +00:00
|
|
|
if (IsComment(rmode_)) {
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (%s)", reinterpret_cast<char*>(data_));
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (rmode_ == EMBEDDED_OBJECT) {
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (");
|
|
|
|
target_object()->ShortPrint(out);
|
|
|
|
PrintF(out, ")");
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (rmode_ == EXTERNAL_REFERENCE) {
|
2008-07-03 15:10:15 +00:00
|
|
|
ExternalReferenceEncoder ref_encoder;
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (%s) (%p)",
|
2008-07-03 15:10:15 +00:00
|
|
|
ref_encoder.NameOfAddress(*target_reference_address()),
|
|
|
|
*target_reference_address());
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (IsCodeTarget(rmode_)) {
|
2008-12-09 12:53:59 +00:00
|
|
|
Code* code = Code::GetCodeFromTargetAddress(target_address());
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()),
|
|
|
|
target_address());
|
2011-04-27 15:02:59 +00:00
|
|
|
if (rmode_ == CODE_TARGET_WITH_ID) {
|
|
|
|
PrintF(" (id=%d)", static_cast<int>(data_));
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (IsPosition(rmode_)) {
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (%" V8_PTR_PREFIX "d)", data());
|
2011-04-07 11:29:40 +00:00
|
|
|
} else if (rmode_ == RelocInfo::RUNTIME_ENTRY &&
|
|
|
|
Isolate::Current()->deoptimizer_data() != NULL) {
|
2010-12-07 11:31:57 +00:00
|
|
|
// Depotimization bailouts are stored as runtime entries.
|
|
|
|
int id = Deoptimizer::GetDeoptimizationId(
|
|
|
|
target_address(), Deoptimizer::EAGER);
|
|
|
|
if (id != Deoptimizer::kNotDeoptimizationEntry) {
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, " (deoptimization bailout %d)", id);
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 10:38:19 +00:00
|
|
|
PrintF(out, "\n");
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2008-08-13 09:32:07 +00:00
|
|
|
#endif // ENABLE_DISASSEMBLER
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2008-08-13 09:32:07 +00:00
|
|
|
#ifdef DEBUG
|
2008-07-03 15:10:15 +00:00
|
|
|
void RelocInfo::Verify() {
|
|
|
|
switch (rmode_) {
|
2008-09-22 13:57:03 +00:00
|
|
|
case EMBEDDED_OBJECT:
|
2008-07-03 15:10:15 +00:00
|
|
|
Object::VerifyPointer(target_object());
|
|
|
|
break;
|
2010-12-07 11:31:57 +00:00
|
|
|
case GLOBAL_PROPERTY_CELL:
|
|
|
|
Object::VerifyPointer(target_cell());
|
|
|
|
break;
|
2010-02-08 13:44:49 +00:00
|
|
|
case DEBUG_BREAK:
|
|
|
|
#ifndef ENABLE_DEBUGGER_SUPPORT
|
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
#endif
|
2008-09-22 13:57:03 +00:00
|
|
|
case CONSTRUCT_CALL:
|
|
|
|
case CODE_TARGET_CONTEXT:
|
2011-04-27 15:02:59 +00:00
|
|
|
case CODE_TARGET_WITH_ID:
|
2008-09-22 13:57:03 +00:00
|
|
|
case CODE_TARGET: {
|
2008-07-03 15:10:15 +00:00
|
|
|
// convert inline target address to code object
|
|
|
|
Address addr = target_address();
|
|
|
|
ASSERT(addr != NULL);
|
|
|
|
// Check that we can find the right code object.
|
2009-09-15 11:39:47 +00:00
|
|
|
Code* code = Code::GetCodeFromTargetAddress(addr);
|
2011-03-18 20:35:07 +00:00
|
|
|
Object* found = HEAP->FindCodeObject(addr);
|
2008-07-03 15:10:15 +00:00
|
|
|
ASSERT(found->IsCode());
|
|
|
|
ASSERT(code->address() == HeapObject::cast(found)->address());
|
|
|
|
break;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
case RUNTIME_ENTRY:
|
|
|
|
case JS_RETURN:
|
|
|
|
case COMMENT:
|
|
|
|
case POSITION:
|
|
|
|
case STATEMENT_POSITION:
|
|
|
|
case EXTERNAL_REFERENCE:
|
|
|
|
case INTERNAL_REFERENCE:
|
2010-06-08 12:04:49 +00:00
|
|
|
case DEBUG_BREAK_SLOT:
|
2008-09-22 13:57:03 +00:00
|
|
|
case NONE:
|
2008-07-03 15:10:15 +00:00
|
|
|
break;
|
2008-09-22 13:57:03 +00:00
|
|
|
case NUMBER_OF_MODES:
|
2008-07-03 15:10:15 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Implementation of ExternalReference
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate)
|
|
|
|
: address_(Redirect(isolate, Builtins::c_function_address(id))) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2011-02-04 13:43:38 +00:00
|
|
|
ExternalReference::ExternalReference(
|
2011-03-22 13:20:04 +00:00
|
|
|
ApiFunction* fun,
|
|
|
|
Type type = ExternalReference::BUILTIN_CALL,
|
|
|
|
Isolate* isolate = NULL)
|
|
|
|
: address_(Redirect(isolate, fun->address(), type)) {}
|
2009-11-04 08:51:48 +00:00
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(Builtins::Name name, Isolate* isolate)
|
|
|
|
: address_(isolate->builtins()->builtin_address(name)) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(Runtime::FunctionId id,
|
|
|
|
Isolate* isolate)
|
|
|
|
: address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(const Runtime::Function* f,
|
|
|
|
Isolate* isolate)
|
|
|
|
: address_(Redirect(isolate, f->entry)) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
ExternalReference ExternalReference::isolate_address() {
|
|
|
|
return ExternalReference(Isolate::Current());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(const IC_Utility& ic_utility,
|
|
|
|
Isolate* isolate)
|
|
|
|
: address_(Redirect(isolate, ic_utility.address())) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(const Debug_Address& debug_address,
|
|
|
|
Isolate* isolate)
|
|
|
|
: address_(debug_address.address(isolate)) {}
|
2009-04-20 16:36:13 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
ExternalReference::ExternalReference(StatsCounter* counter)
|
|
|
|
: address_(reinterpret_cast<Address>(counter->GetInternalPointer())) {}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::ExternalReference(Isolate::AddressId id, Isolate* isolate)
|
|
|
|
: address_(isolate->get_address_from_id(id)) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
ExternalReference::ExternalReference(const SCTableReference& table_ref)
|
|
|
|
: address_(table_ref.address()) {}
|
|
|
|
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
ExternalReference ExternalReference::
|
|
|
|
incremental_marking_record_write_function(Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(
|
|
|
|
isolate,
|
|
|
|
FUNCTION_ADDR(IncrementalMarking::RecordWriteFromCode)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::
|
|
|
|
incremental_evacuation_record_write_function(Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(
|
|
|
|
isolate,
|
|
|
|
FUNCTION_ADDR(IncrementalMarking::RecordWriteForEvacuationFromCode)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::
|
|
|
|
store_buffer_overflow_function(Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(
|
|
|
|
isolate,
|
|
|
|
FUNCTION_ADDR(StoreBuffer::StoreBufferOverflow)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-16 09:23:48 +00:00
|
|
|
ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(CPU::FlushICache)));
|
|
|
|
}
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) {
|
2011-09-19 18:36:47 +00:00
|
|
|
return
|
|
|
|
ExternalReference(Redirect(isolate, FUNCTION_ADDR(Runtime::PerformGC)));
|
2009-06-09 09:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::fill_heap_number_with_random_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(
|
|
|
|
isolate,
|
|
|
|
FUNCTION_ADDR(V8::FillHeapNumberWithRandom)));
|
2009-06-15 08:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::delete_handle_scope_extensions(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(
|
|
|
|
isolate,
|
|
|
|
FUNCTION_ADDR(HandleScope::DeleteExtensions)));
|
2010-10-21 14:21:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::random_uint32_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(V8::Random)));
|
2010-04-12 10:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::transcendental_cache_array_address(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(
|
|
|
|
isolate->transcendental_cache()->cache_array_address());
|
2010-02-23 10:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::new_deoptimizer_function(
|
|
|
|
Isolate* isolate) {
|
2010-12-07 11:31:57 +00:00
|
|
|
return ExternalReference(
|
2011-03-22 13:20:04 +00:00
|
|
|
Redirect(isolate, FUNCTION_ADDR(Deoptimizer::New)));
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::compute_output_frames_function(
|
|
|
|
Isolate* isolate) {
|
2010-12-07 11:31:57 +00:00
|
|
|
return ExternalReference(
|
2011-03-22 13:20:04 +00:00
|
|
|
Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames)));
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::keyed_lookup_cache_keys(Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->keyed_lookup_cache()->keys_address());
|
2009-12-10 15:10:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::keyed_lookup_cache_field_offsets(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(
|
|
|
|
isolate->keyed_lookup_cache()->field_offsets_address());
|
2009-12-10 15:10:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-20 12:27:10 +00:00
|
|
|
ExternalReference ExternalReference::roots_array_start(Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->heap()->roots_array_start());
|
2009-08-24 11:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_stack_limit(Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->stack_guard()->address_of_jslimit());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_real_stack_limit(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->stack_guard()->address_of_real_jslimit());
|
2009-11-05 13:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_regexp_stack_limit(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->regexp_stack()->limit_address());
|
2009-01-12 13:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::new_space_start(Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->heap()->NewSpaceStart());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->heap()->store_buffer()->TopAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::new_space_mask(Isolate* isolate) {
|
2011-09-19 18:36:47 +00:00
|
|
|
return ExternalReference(reinterpret_cast<Address>(
|
|
|
|
isolate->heap()->NewSpaceMask()));
|
2010-03-02 11:54:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::new_space_allocation_top_address(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::heap_always_allocate_scope_depth(
|
|
|
|
Isolate* isolate) {
|
|
|
|
Heap* heap = isolate->heap();
|
|
|
|
return ExternalReference(heap->always_allocate_scope_depth_address());
|
2008-10-30 09:15:58 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::new_space_allocation_limit_address(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 08:51:48 +00:00
|
|
|
|
2010-10-21 14:21:00 +00:00
|
|
|
ExternalReference ExternalReference::handle_scope_level_address() {
|
|
|
|
return ExternalReference(HandleScope::current_level_address());
|
2009-11-04 08:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::handle_scope_next_address() {
|
|
|
|
return ExternalReference(HandleScope::current_next_address());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::handle_scope_limit_address() {
|
|
|
|
return ExternalReference(HandleScope::current_limit_address());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::scheduled_exception_address(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->scheduled_exception_address());
|
2009-11-04 08:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
ExternalReference ExternalReference::address_of_min_int() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::min_int)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::address_of_one_half() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::one_half)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-11 13:48:49 +00:00
|
|
|
ExternalReference ExternalReference::address_of_minus_zero() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::minus_zero)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-16 14:10:56 +00:00
|
|
|
ExternalReference ExternalReference::address_of_zero() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::zero)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::address_of_uint8_max_value() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::uint8_max_value)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 14:32:40 +00:00
|
|
|
ExternalReference ExternalReference::address_of_negative_infinity() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::negative_infinity)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-13 13:50:27 +00:00
|
|
|
ExternalReference ExternalReference::address_of_canonical_non_hole_nan() {
|
2011-03-17 15:46:42 +00:00
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
2011-07-13 13:50:27 +00:00
|
|
|
const_cast<double*>(&DoubleConstant::canonical_non_hole_nan)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExternalReference ExternalReference::address_of_the_hole_nan() {
|
|
|
|
return ExternalReference(reinterpret_cast<void*>(
|
|
|
|
const_cast<double*>(&DoubleConstant::the_hole_nan)));
|
2011-03-17 15:46:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-19 19:30:11 +00:00
|
|
|
#ifndef V8_INTERPRETED_REGEXP
|
2009-08-31 12:40:37 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::re_check_stack_guard_state(
|
|
|
|
Isolate* isolate) {
|
2009-08-31 12:40:37 +00:00
|
|
|
Address function;
|
|
|
|
#ifdef V8_TARGET_ARCH_X64
|
|
|
|
function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState);
|
|
|
|
#elif V8_TARGET_ARCH_IA32
|
|
|
|
function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState);
|
|
|
|
#elif V8_TARGET_ARCH_ARM
|
|
|
|
function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState);
|
2011-03-28 13:05:36 +00:00
|
|
|
#elif V8_TARGET_ARCH_MIPS
|
|
|
|
function = FUNCTION_ADDR(RegExpMacroAssemblerMIPS::CheckStackGuardState);
|
2009-08-31 12:40:37 +00:00
|
|
|
#else
|
2010-01-29 10:33:27 +00:00
|
|
|
UNREACHABLE();
|
2009-08-31 12:40:37 +00:00
|
|
|
#endif
|
2011-03-22 13:20:04 +00:00
|
|
|
return ExternalReference(Redirect(isolate, function));
|
2009-08-31 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::re_grow_stack(Isolate* isolate) {
|
2009-08-31 12:40:37 +00:00
|
|
|
return ExternalReference(
|
2011-03-22 13:20:04 +00:00
|
|
|
Redirect(isolate, FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack)));
|
2009-08-31 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::re_case_insensitive_compare_uc16(
|
|
|
|
Isolate* isolate) {
|
2009-08-31 12:40:37 +00:00
|
|
|
return ExternalReference(Redirect(
|
2011-03-22 13:20:04 +00:00
|
|
|
isolate,
|
2009-08-31 12:40:37 +00:00
|
|
|
FUNCTION_ADDR(NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16)));
|
|
|
|
}
|
|
|
|
|
2010-01-18 09:49:50 +00:00
|
|
|
ExternalReference ExternalReference::re_word_character_map() {
|
|
|
|
return ExternalReference(
|
|
|
|
NativeRegExpMacroAssembler::word_character_map_address());
|
|
|
|
}
|
2010-01-06 11:09:30 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_static_offsets_vector(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(
|
|
|
|
OffsetsVector::static_offsets_vector_address(isolate));
|
2010-01-06 11:09:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_regexp_stack_memory_address(
|
|
|
|
Isolate* isolate) {
|
2011-03-18 20:35:07 +00:00
|
|
|
return ExternalReference(
|
2011-03-22 13:20:04 +00:00
|
|
|
isolate->regexp_stack()->memory_address());
|
2010-01-06 11:09:30 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::address_of_regexp_stack_memory_size(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->regexp_stack()->memory_size_address());
|
2010-01-06 11:09:30 +00:00
|
|
|
}
|
|
|
|
|
2010-04-19 19:30:11 +00:00
|
|
|
#endif // V8_INTERPRETED_REGEXP
|
2009-08-31 12:40:37 +00:00
|
|
|
|
2009-04-16 09:30:23 +00:00
|
|
|
|
|
|
|
static double add_two_doubles(double x, double y) {
|
|
|
|
return x + y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static double sub_two_doubles(double x, double y) {
|
|
|
|
return x - y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static double mul_two_doubles(double x, double y) {
|
|
|
|
return x * y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-03 12:44:31 +00:00
|
|
|
static double div_two_doubles(double x, double y) {
|
|
|
|
return x / y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static double mod_two_doubles(double x, double y) {
|
2010-01-18 08:36:06 +00:00
|
|
|
return modulo(x, y);
|
2009-07-03 12:44:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-02 14:40:38 +00:00
|
|
|
static double math_sin_double(double x) {
|
|
|
|
return sin(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static double math_cos_double(double x) {
|
|
|
|
return cos(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-25 13:15:31 +00:00
|
|
|
static double math_tan_double(double x) {
|
|
|
|
return tan(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-02 14:40:38 +00:00
|
|
|
static double math_log_double(double x) {
|
|
|
|
return log(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::math_sin_double_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(math_sin_double),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_CALL));
|
2011-03-02 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::math_cos_double_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(math_cos_double),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_CALL));
|
2011-03-02 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-25 13:15:31 +00:00
|
|
|
ExternalReference ExternalReference::math_tan_double_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(math_tan_double),
|
|
|
|
BUILTIN_FP_CALL));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::math_log_double_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(math_log_double),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_CALL));
|
2011-03-02 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 14:32:40 +00:00
|
|
|
// Helper function to compute x^y, where y is known to be an
|
|
|
|
// integer. Uses binary decomposition to limit the number of
|
|
|
|
// multiplications; see the discussion in "Hacker's Delight" by Henry
|
|
|
|
// S. Warren, Jr., figure 11-6, page 213.
|
|
|
|
double power_double_int(double x, int y) {
|
|
|
|
double m = (y < 0) ? 1 / x : x;
|
|
|
|
unsigned n = (y < 0) ? -y : y;
|
|
|
|
double p = 1;
|
|
|
|
while (n != 0) {
|
|
|
|
if ((n & 1) != 0) p *= m;
|
|
|
|
m *= m;
|
|
|
|
if ((n & 2) != 0) p *= m;
|
|
|
|
m *= m;
|
|
|
|
n >>= 2;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double power_double_double(double x, double y) {
|
2011-12-02 08:06:37 +00:00
|
|
|
// The checks for special cases can be dropped in ia32 because it has already
|
|
|
|
// been done in generated code before bailing out here.
|
2011-12-07 16:15:18 +00:00
|
|
|
if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) return OS::nan_value();
|
2010-12-08 14:32:40 +00:00
|
|
|
return pow(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::power_double_double_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(power_double_double),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_FP_CALL));
|
2010-12-08 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::power_double_int_function(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(power_double_int),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_INT_CALL));
|
2010-12-08 14:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-18 08:36:06 +00:00
|
|
|
static int native_compare_doubles(double y, double x) {
|
|
|
|
if (x == y) return EQUAL;
|
|
|
|
return x < y ? LESS : GREATER;
|
2011-10-20 10:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EvalComparison(Token::Value op, double op1, double op2) {
|
|
|
|
ASSERT(Token::IsCompareOp(op));
|
|
|
|
switch (op) {
|
|
|
|
case Token::EQ:
|
|
|
|
case Token::EQ_STRICT: return (op1 == op2);
|
|
|
|
case Token::NE: return (op1 != op2);
|
|
|
|
case Token::LT: return (op1 < op2);
|
|
|
|
case Token::GT: return (op1 > op2);
|
|
|
|
case Token::LTE: return (op1 <= op2);
|
|
|
|
case Token::GTE: return (op1 >= op2);
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-29 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-16 09:30:23 +00:00
|
|
|
ExternalReference ExternalReference::double_fp_operation(
|
2011-03-22 13:20:04 +00:00
|
|
|
Token::Value operation, Isolate* isolate) {
|
2009-04-16 09:30:23 +00:00
|
|
|
typedef double BinaryFPOperation(double x, double y);
|
|
|
|
BinaryFPOperation* function = NULL;
|
|
|
|
switch (operation) {
|
|
|
|
case Token::ADD:
|
|
|
|
function = &add_two_doubles;
|
|
|
|
break;
|
|
|
|
case Token::SUB:
|
|
|
|
function = &sub_two_doubles;
|
|
|
|
break;
|
|
|
|
case Token::MUL:
|
|
|
|
function = &mul_two_doubles;
|
|
|
|
break;
|
2009-07-03 12:44:31 +00:00
|
|
|
case Token::DIV:
|
|
|
|
function = &div_two_doubles;
|
|
|
|
break;
|
|
|
|
case Token::MOD:
|
|
|
|
function = &mod_two_doubles;
|
|
|
|
break;
|
2009-04-16 09:30:23 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
2011-03-22 13:20:04 +00:00
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(function),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_FP_CALL));
|
2009-04-16 09:30:23 +00:00
|
|
|
}
|
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::compare_doubles(Isolate* isolate) {
|
|
|
|
return ExternalReference(Redirect(isolate,
|
|
|
|
FUNCTION_ADDR(native_compare_doubles),
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_COMPARE_CALL));
|
2009-06-29 13:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::debug_break(Isolate* isolate) {
|
2011-03-30 14:17:39 +00:00
|
|
|
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug_Break)));
|
2009-04-20 16:36:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference ExternalReference::debug_step_in_fp_address(
|
|
|
|
Isolate* isolate) {
|
|
|
|
return ExternalReference(isolate->debug()->step_in_fp_addr());
|
2009-04-20 16:36:13 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-11-04 15:12:03 +00:00
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
void PositionsRecorder::RecordPosition(int pos) {
|
2010-11-04 15:12:03 +00:00
|
|
|
ASSERT(pos != RelocInfo::kNoPosition);
|
|
|
|
ASSERT(pos >= 0);
|
2010-11-30 13:17:36 +00:00
|
|
|
state_.current_position = pos;
|
2011-01-18 16:11:01 +00:00
|
|
|
#ifdef ENABLE_GDB_JIT_INTERFACE
|
|
|
|
if (gdbjit_lineinfo_ != NULL) {
|
|
|
|
gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, false);
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-04 15:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PositionsRecorder::RecordStatementPosition(int pos) {
|
|
|
|
ASSERT(pos != RelocInfo::kNoPosition);
|
|
|
|
ASSERT(pos >= 0);
|
2010-11-30 13:17:36 +00:00
|
|
|
state_.current_statement_position = pos;
|
2011-01-18 16:11:01 +00:00
|
|
|
#ifdef ENABLE_GDB_JIT_INTERFACE
|
|
|
|
if (gdbjit_lineinfo_ != NULL) {
|
|
|
|
gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, true);
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-04 15:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PositionsRecorder::WriteRecordedPositions() {
|
|
|
|
bool written = false;
|
|
|
|
|
|
|
|
// Write the statement position if it is different from what was written last
|
|
|
|
// time.
|
2010-11-30 13:17:36 +00:00
|
|
|
if (state_.current_statement_position != state_.written_statement_position) {
|
2010-11-04 15:12:03 +00:00
|
|
|
EnsureSpace ensure_space(assembler_);
|
|
|
|
assembler_->RecordRelocInfo(RelocInfo::STATEMENT_POSITION,
|
2010-11-30 13:17:36 +00:00
|
|
|
state_.current_statement_position);
|
|
|
|
state_.written_statement_position = state_.current_statement_position;
|
2010-11-04 15:12:03 +00:00
|
|
|
written = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the position if it is different from what was written last time and
|
2010-11-30 13:17:36 +00:00
|
|
|
// also different from the written statement position.
|
|
|
|
if (state_.current_position != state_.written_position &&
|
|
|
|
state_.current_position != state_.written_statement_position) {
|
2010-11-04 15:12:03 +00:00
|
|
|
EnsureSpace ensure_space(assembler_);
|
2010-11-30 13:17:36 +00:00
|
|
|
assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position);
|
|
|
|
state_.written_position = state_.current_position;
|
2010-11-04 15:12:03 +00:00
|
|
|
written = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return whether something was written.
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|