2008-07-03 15:10:15 +00:00
|
|
|
// Copyright (c) 1994-2006 Sun Microsystems Inc.
|
|
|
|
// 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.
|
2012-01-25 16:31:25 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_ASSEMBLER_H_
|
|
|
|
#define V8_ASSEMBLER_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2012-01-25 16:31:25 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/builtins.h"
|
|
|
|
#include "src/gdb-jit.h"
|
|
|
|
#include "src/isolate.h"
|
2014-09-25 07:16:15 +00:00
|
|
|
#include "src/runtime/runtime.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/token.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
2012-01-25 16:31:25 +00:00
|
|
|
|
|
|
|
class ApiFunction;
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-04-24 14:05:37 +00:00
|
|
|
class StatsCounter;
|
2011-03-22 13:20:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Platform independent assembler base class.
|
|
|
|
|
|
|
|
class AssemblerBase: public Malloced {
|
|
|
|
public:
|
2012-11-22 10:28:29 +00:00
|
|
|
AssemblerBase(Isolate* isolate, void* buffer, int buffer_size);
|
|
|
|
virtual ~AssemblerBase();
|
2011-03-22 13:20:04 +00:00
|
|
|
|
|
|
|
Isolate* isolate() const { return isolate_; }
|
2012-11-09 13:10:10 +00:00
|
|
|
int jit_cookie() const { return jit_cookie_; }
|
|
|
|
|
2012-11-09 13:43:48 +00:00
|
|
|
bool emit_debug_code() const { return emit_debug_code_; }
|
|
|
|
void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
|
|
|
|
|
2014-05-16 15:18:24 +00:00
|
|
|
bool serializer_enabled() const { return serializer_enabled_; }
|
2014-07-08 09:04:08 +00:00
|
|
|
void enable_serializer() { serializer_enabled_ = true; }
|
2014-05-16 15:18:24 +00:00
|
|
|
|
2012-11-09 13:10:10 +00:00
|
|
|
bool predictable_code_size() const { return predictable_code_size_; }
|
|
|
|
void set_predictable_code_size(bool value) { predictable_code_size_ = value; }
|
2011-03-22 13:20:04 +00:00
|
|
|
|
2013-03-05 10:48:16 +00:00
|
|
|
uint64_t enabled_cpu_features() const { return enabled_cpu_features_; }
|
|
|
|
void set_enabled_cpu_features(uint64_t features) {
|
|
|
|
enabled_cpu_features_ = features;
|
|
|
|
}
|
|
|
|
bool IsEnabled(CpuFeature f) {
|
|
|
|
return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0;
|
|
|
|
}
|
|
|
|
|
2015-06-03 03:02:26 +00:00
|
|
|
bool is_ool_constant_pool_available() const {
|
|
|
|
if (FLAG_enable_ool_constant_pool) {
|
|
|
|
return ool_constant_pool_available_;
|
2014-10-13 14:41:33 +00:00
|
|
|
} else {
|
2015-06-03 03:02:26 +00:00
|
|
|
// Out-of-line constant pool not supported on this architecture.
|
2014-10-13 14:41:33 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-12 09:23:26 +00:00
|
|
|
// Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for
|
|
|
|
// cross-snapshotting.
|
|
|
|
static void QuietNaN(HeapObject* nan) { }
|
|
|
|
|
2012-11-22 10:28:29 +00:00
|
|
|
int pc_offset() const { return static_cast<int>(pc_ - buffer_); }
|
|
|
|
|
2014-03-20 09:10:15 +00:00
|
|
|
// This function is called when code generation is aborted, so that
|
|
|
|
// the assembler could clean up internal data structures.
|
|
|
|
virtual void AbortedCodeGeneration() { }
|
|
|
|
|
2012-11-22 10:28:29 +00:00
|
|
|
static const int kMinimalBufferSize = 4*KB;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// The buffer into which code and relocation info are generated. It could
|
|
|
|
// either be owned by the assembler or be provided externally.
|
|
|
|
byte* buffer_;
|
|
|
|
int buffer_size_;
|
|
|
|
bool own_buffer_;
|
|
|
|
|
2015-06-03 03:02:26 +00:00
|
|
|
void set_ool_constant_pool_available(bool available) {
|
|
|
|
if (FLAG_enable_ool_constant_pool) {
|
|
|
|
ool_constant_pool_available_ = available;
|
2014-10-13 14:41:33 +00:00
|
|
|
} else {
|
2015-06-03 03:02:26 +00:00
|
|
|
// Out-of-line constant pool not supported on this architecture.
|
2014-10-13 14:41:33 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-22 10:28:29 +00:00
|
|
|
// The program counter, which points into the buffer above and moves forward.
|
|
|
|
byte* pc_;
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
private:
|
|
|
|
Isolate* isolate_;
|
2011-05-11 14:16:24 +00:00
|
|
|
int jit_cookie_;
|
2013-03-05 10:48:16 +00:00
|
|
|
uint64_t enabled_cpu_features_;
|
2012-11-09 13:43:48 +00:00
|
|
|
bool emit_debug_code_;
|
2012-11-09 13:10:10 +00:00
|
|
|
bool predictable_code_size_;
|
2014-05-16 15:18:24 +00:00
|
|
|
bool serializer_enabled_;
|
2014-10-13 14:41:33 +00:00
|
|
|
|
|
|
|
// Indicates whether the constant pool can be accessed, which is only possible
|
|
|
|
// if the pp register points to the current code object's constant pool.
|
2015-06-03 03:02:26 +00:00
|
|
|
bool ool_constant_pool_available_;
|
2014-10-13 14:41:33 +00:00
|
|
|
|
|
|
|
// Constant pool.
|
|
|
|
friend class FrameAndConstantPoolScope;
|
|
|
|
friend class ConstantPoolUnavailableScope;
|
2012-11-09 13:10:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-16 02:06:14 +00:00
|
|
|
// Avoids emitting debug code during the lifetime of this scope object.
|
|
|
|
class DontEmitDebugCodeScope BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
explicit DontEmitDebugCodeScope(AssemblerBase* assembler)
|
|
|
|
: assembler_(assembler), old_value_(assembler->emit_debug_code()) {
|
|
|
|
assembler_->set_emit_debug_code(false);
|
|
|
|
}
|
|
|
|
~DontEmitDebugCodeScope() {
|
|
|
|
assembler_->set_emit_debug_code(old_value_);
|
2014-05-09 12:59:24 +00:00
|
|
|
}
|
2014-04-16 02:06:14 +00:00
|
|
|
private:
|
|
|
|
AssemblerBase* assembler_;
|
|
|
|
bool old_value_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-09 13:10:10 +00:00
|
|
|
// Avoids using instructions that vary in size in unpredictable ways between the
|
|
|
|
// snapshot and the running VM.
|
|
|
|
class PredictableCodeSizeScope {
|
|
|
|
public:
|
2012-11-22 14:59:52 +00:00
|
|
|
PredictableCodeSizeScope(AssemblerBase* assembler, int expected_size);
|
|
|
|
~PredictableCodeSizeScope();
|
2012-11-09 13:10:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
AssemblerBase* assembler_;
|
2012-11-22 14:59:52 +00:00
|
|
|
int expected_size_;
|
|
|
|
int start_offset_;
|
2012-11-09 13:10:10 +00:00
|
|
|
bool old_value_;
|
2011-03-22 13:20:04 +00:00
|
|
|
};
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2013-03-05 10:48:16 +00:00
|
|
|
// Enable a specified feature within a scope.
|
|
|
|
class CpuFeatureScope BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG
|
|
|
|
CpuFeatureScope(AssemblerBase* assembler, CpuFeature f);
|
|
|
|
~CpuFeatureScope();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AssemblerBase* assembler_;
|
|
|
|
uint64_t old_enabled_;
|
|
|
|
#else
|
|
|
|
CpuFeatureScope(AssemblerBase* assembler, CpuFeature f) {}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-16 15:18:24 +00:00
|
|
|
// CpuFeatures keeps track of which features are supported by the target CPU.
|
|
|
|
// Supported features must be enabled by a CpuFeatureScope before use.
|
|
|
|
// Example:
|
|
|
|
// if (assembler->IsSupported(SSE3)) {
|
|
|
|
// CpuFeatureScope fscope(assembler, SSE3);
|
|
|
|
// // Generate code containing SSE3 instructions.
|
|
|
|
// } else {
|
|
|
|
// // Generate alternative code.
|
|
|
|
// }
|
|
|
|
class CpuFeatures : public AllStatic {
|
2013-09-17 13:02:25 +00:00
|
|
|
public:
|
2014-05-16 15:18:24 +00:00
|
|
|
static void Probe(bool cross_compile) {
|
|
|
|
STATIC_ASSERT(NUMBER_OF_CPU_FEATURES <= kBitsPerInt);
|
|
|
|
if (initialized_) return;
|
|
|
|
initialized_ = true;
|
|
|
|
ProbeImpl(cross_compile);
|
|
|
|
}
|
|
|
|
|
2014-08-05 13:26:55 +00:00
|
|
|
static unsigned SupportedFeatures() {
|
|
|
|
Probe(false);
|
|
|
|
return supported_;
|
|
|
|
}
|
|
|
|
|
2014-05-16 15:18:24 +00:00
|
|
|
static bool IsSupported(CpuFeature f) {
|
|
|
|
return (supported_ & (1u << f)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool SupportsCrankshaft();
|
|
|
|
|
|
|
|
static inline unsigned cache_line_size() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(cache_line_size_ != 0);
|
2014-05-16 15:18:24 +00:00
|
|
|
return cache_line_size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintTarget();
|
|
|
|
static void PrintFeatures();
|
2013-09-17 13:02:25 +00:00
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
// Flush instruction cache.
|
|
|
|
static void FlushICache(void* start, size_t size);
|
|
|
|
|
2013-09-17 13:02:25 +00:00
|
|
|
private:
|
2014-05-16 15:18:24 +00:00
|
|
|
// Platform-dependent implementation.
|
|
|
|
static void ProbeImpl(bool cross_compile);
|
|
|
|
|
|
|
|
static unsigned supported_;
|
|
|
|
static unsigned cache_line_size_;
|
|
|
|
static bool initialized_;
|
|
|
|
friend class ExternalReference;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
2013-09-17 13:02:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Labels represent pc locations; they are typically jump or call targets.
|
|
|
|
// After declaration, a label can be freely used to denote known or (yet)
|
|
|
|
// unknown pc location. Assembler::bind() is used to bind a label to the
|
|
|
|
// current pc. A label can be bound only once.
|
|
|
|
|
2014-11-06 14:59:07 +00:00
|
|
|
class Label {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2011-05-10 09:03:42 +00:00
|
|
|
enum Distance {
|
|
|
|
kNear, kFar
|
|
|
|
};
|
|
|
|
|
|
|
|
INLINE(Label()) {
|
|
|
|
Unuse();
|
|
|
|
UnuseNear();
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-06-16 15:18:48 +00:00
|
|
|
INLINE(~Label()) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!is_linked());
|
|
|
|
DCHECK(!is_near_linked());
|
2011-06-16 15:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
INLINE(void Unuse()) { pos_ = 0; }
|
|
|
|
INLINE(void UnuseNear()) { near_link_pos_ = 0; }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-06-16 15:18:48 +00:00
|
|
|
INLINE(bool is_bound() const) { return pos_ < 0; }
|
|
|
|
INLINE(bool is_unused() const) { return pos_ == 0 && near_link_pos_ == 0; }
|
|
|
|
INLINE(bool is_linked() const) { return pos_ > 0; }
|
2011-05-10 09:03:42 +00:00
|
|
|
INLINE(bool is_near_linked() const) { return near_link_pos_ > 0; }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Returns the position of bound or linked labels. Cannot be used
|
|
|
|
// for unused labels.
|
|
|
|
int pos() const;
|
2011-05-10 09:03:42 +00:00
|
|
|
int near_link_pos() const { return near_link_pos_ - 1; }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// pos_ encodes both the binding state (via its sign)
|
|
|
|
// and the binding position (via its value) of a label.
|
|
|
|
//
|
|
|
|
// pos_ < 0 bound label, pos() returns the jump target position
|
|
|
|
// pos_ == 0 unused label
|
|
|
|
// pos_ > 0 linked label, pos() returns the last reference position
|
|
|
|
int pos_;
|
|
|
|
|
2011-05-10 09:03:42 +00:00
|
|
|
// Behaves like |pos_| in the "> 0" case, but for near jumps to this label.
|
|
|
|
int near_link_pos_;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void bind_to(int pos) {
|
|
|
|
pos_ = -pos - 1;
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(is_bound());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-05-10 09:03:42 +00:00
|
|
|
void link_to(int pos, Distance distance = kFar) {
|
|
|
|
if (distance == kNear) {
|
|
|
|
near_link_pos_ = pos + 1;
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(is_near_linked());
|
2011-05-10 09:03:42 +00:00
|
|
|
} else {
|
|
|
|
pos_ = pos + 1;
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(is_linked());
|
2011-05-10 09:03:42 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
friend class Assembler;
|
|
|
|
friend class Displacement;
|
2008-11-28 10:37:06 +00:00
|
|
|
friend class RegExpMacroAssemblerIrregexp;
|
2014-03-14 15:14:42 +00:00
|
|
|
|
2014-03-21 09:28:26 +00:00
|
|
|
#if V8_TARGET_ARCH_ARM64
|
|
|
|
// On ARM64, the Assembler keeps track of pointers to Labels to resolve
|
|
|
|
// branches to distant targets. Copying labels would confuse the Assembler.
|
2014-03-14 15:14:42 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(Label); // NOLINT
|
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
enum SaveFPRegsMode { kDontSaveFPRegs, kSaveFPRegs };
|
|
|
|
|
2014-05-20 09:21:45 +00:00
|
|
|
// Specifies whether to perform icache flush operations on RelocInfo updates.
|
|
|
|
// If FLUSH_ICACHE_IF_NEEDED, the icache will always be flushed if an
|
|
|
|
// instruction was modified. If SKIP_ICACHE_FLUSH the flush will always be
|
|
|
|
// skipped (only use this if you will flush the icache manually before it is
|
|
|
|
// executed).
|
|
|
|
enum ICacheFlushMode { FLUSH_ICACHE_IF_NEEDED, SKIP_ICACHE_FLUSH };
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Relocation information
|
|
|
|
|
2008-09-18 13:42:39 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Relocation information consists of the address (pc) of the datum
|
|
|
|
// to which the relocation information applies, the relocation mode
|
|
|
|
// (rmode), and an optional data field. The relocation mode may be
|
|
|
|
// "descriptive" and not indicate a need for relocation, but simply
|
|
|
|
// describe a property of the datum. Such rmodes are useful for GC
|
|
|
|
// and nice disassembly output.
|
|
|
|
|
2014-04-29 14:14:06 +00:00
|
|
|
class RelocInfo {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2008-09-22 13:57:03 +00:00
|
|
|
// The constant kNoPosition is used with the collecting of source positions
|
|
|
|
// in the relocation information. Two types of source positions are collected
|
|
|
|
// "position" (RelocMode position) and "statement position" (RelocMode
|
|
|
|
// statement_position). The "position" is collected at places in the source
|
|
|
|
// code which are of interest when making stack traces to pin-point the source
|
|
|
|
// location of a stack frame as close as possible. The "statement position" is
|
|
|
|
// collected at the beginning at each statement, and is used to indicate
|
|
|
|
// possible break locations. kNoPosition is used to indicate an
|
|
|
|
// invalid/uninitialized position value.
|
|
|
|
static const int kNoPosition = -1;
|
|
|
|
|
2011-02-15 14:36:12 +00:00
|
|
|
// This string is used to add padding comments to the reloc info in cases
|
|
|
|
// where we are not sure to have enough space for patching in during
|
|
|
|
// lazy deoptimization. This is the case if we have indirect calls for which
|
|
|
|
// we do not normally record relocation info.
|
2011-08-05 11:32:46 +00:00
|
|
|
static const char* const kFillerCommentString;
|
2011-02-15 14:36:12 +00:00
|
|
|
|
2011-02-24 10:29:01 +00:00
|
|
|
// The minimum size of a comment is equal to three bytes for the extra tagged
|
|
|
|
// pc + the tag for the data, and kPointerSize for the actual pointer to the
|
2011-02-22 12:28:33 +00:00
|
|
|
// comment.
|
2011-02-24 10:29:01 +00:00
|
|
|
static const int kMinRelocCommentSize = 3 + kPointerSize;
|
2011-02-22 12:28:33 +00:00
|
|
|
|
|
|
|
// The maximum size for a call instruction including pc-jump.
|
|
|
|
static const int kMaxCallSize = 6;
|
|
|
|
|
2011-03-25 10:29:34 +00:00
|
|
|
// The maximum pc delta that will use the short encoding.
|
|
|
|
static const int kMaxSmallPCDelta;
|
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
enum Mode {
|
|
|
|
// Please note the order is important (see IsCodeTarget, IsGCRelocMode).
|
2011-04-27 15:02:59 +00:00
|
|
|
CODE_TARGET, // Code target which is not any of the above.
|
|
|
|
CODE_TARGET_WITH_ID,
|
2008-09-22 13:57:03 +00:00
|
|
|
CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
|
2015-02-05 14:51:45 +00:00
|
|
|
DEBUG_BREAK, // Code target for the debugger statement.
|
2008-09-22 13:57:03 +00:00
|
|
|
EMBEDDED_OBJECT,
|
2013-06-12 15:03:44 +00:00
|
|
|
CELL,
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
// Everything after runtime_entry (inclusive) is not GC'ed.
|
|
|
|
RUNTIME_ENTRY,
|
|
|
|
JS_RETURN, // Marks start of the ExitJSFrame code.
|
|
|
|
COMMENT,
|
2015-02-05 14:51:45 +00:00
|
|
|
POSITION, // See comment for kNoPosition above.
|
2008-09-22 13:57:03 +00:00
|
|
|
STATEMENT_POSITION, // See comment for kNoPosition above.
|
2015-02-05 14:51:45 +00:00
|
|
|
DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot.
|
2008-09-22 13:57:03 +00:00
|
|
|
EXTERNAL_REFERENCE, // The address of an external C++ function.
|
|
|
|
INTERNAL_REFERENCE, // An address inside the same function.
|
|
|
|
|
2015-03-13 10:07:54 +00:00
|
|
|
// Encoded internal reference, used only on MIPS, MIPS64 and PPC.
|
|
|
|
INTERNAL_REFERENCE_ENCODED,
|
|
|
|
|
2014-03-21 09:28:26 +00:00
|
|
|
// Marks constant and veneer pools. Only used on ARM and ARM64.
|
2014-03-12 15:40:41 +00:00
|
|
|
// They use a custom noncompact encoding.
|
2012-06-14 11:16:47 +00:00
|
|
|
CONST_POOL,
|
2014-03-12 15:40:41 +00:00
|
|
|
VENEER_POOL,
|
2012-06-14 11:16:47 +00:00
|
|
|
|
2015-02-05 14:51:45 +00:00
|
|
|
DEOPT_REASON, // Deoptimization reason index.
|
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
// add more as needed
|
|
|
|
// Pseudo-types
|
2015-02-05 14:51:45 +00:00
|
|
|
NUMBER_OF_MODES, // There are at most 15 modes with noncompact encoding.
|
|
|
|
NONE32, // never recorded 32-bit value
|
|
|
|
NONE64, // never recorded 64-bit value
|
2012-11-08 12:18:11 +00:00
|
|
|
CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by
|
|
|
|
// code aging.
|
2015-02-17 14:52:16 +00:00
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
FIRST_REAL_RELOC_MODE = CODE_TARGET,
|
2014-03-12 15:40:41 +00:00
|
|
|
LAST_REAL_RELOC_MODE = VENEER_POOL,
|
2012-11-08 12:18:11 +00:00
|
|
|
FIRST_PSEUDO_RELOC_MODE = CODE_AGE_SEQUENCE,
|
|
|
|
LAST_PSEUDO_RELOC_MODE = CODE_AGE_SEQUENCE,
|
2011-04-27 15:02:59 +00:00
|
|
|
LAST_CODE_ENUM = DEBUG_BREAK,
|
2013-06-12 15:03:44 +00:00
|
|
|
LAST_GCED_ENUM = CELL,
|
2011-04-27 15:02:59 +00:00
|
|
|
// Modes <= LAST_COMPACT_ENUM are guaranteed to have compact encoding.
|
2012-06-14 11:16:47 +00:00
|
|
|
LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID,
|
2015-03-16 11:43:28 +00:00
|
|
|
LAST_STANDARD_NONCOMPACT_ENUM = INTERNAL_REFERENCE_ENCODED
|
2008-09-22 13:57:03 +00:00
|
|
|
};
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
RelocInfo() {}
|
2011-09-19 18:36:47 +00:00
|
|
|
|
|
|
|
RelocInfo(byte* pc, Mode rmode, intptr_t data, Code* host)
|
|
|
|
: pc_(pc), rmode_(rmode), data_(data), host_(host) {
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2015-06-03 03:02:26 +00:00
|
|
|
RelocInfo(byte* pc, double data64)
|
|
|
|
: pc_(pc), rmode_(NONE64), data64_(data64), host_(NULL) {
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
static inline bool IsRealRelocMode(Mode mode) {
|
|
|
|
return mode >= FIRST_REAL_RELOC_MODE &&
|
|
|
|
mode <= LAST_REAL_RELOC_MODE;
|
|
|
|
}
|
|
|
|
static inline bool IsPseudoRelocMode(Mode mode) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!IsRealRelocMode(mode));
|
2012-11-08 12:18:11 +00:00
|
|
|
return mode >= FIRST_PSEUDO_RELOC_MODE &&
|
|
|
|
mode <= LAST_PSEUDO_RELOC_MODE;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
static inline bool IsConstructCall(Mode mode) {
|
|
|
|
return mode == CONSTRUCT_CALL;
|
|
|
|
}
|
|
|
|
static inline bool IsCodeTarget(Mode mode) {
|
|
|
|
return mode <= LAST_CODE_ENUM;
|
|
|
|
}
|
2011-10-12 15:43:41 +00:00
|
|
|
static inline bool IsEmbeddedObject(Mode mode) {
|
|
|
|
return mode == EMBEDDED_OBJECT;
|
|
|
|
}
|
2015-04-10 13:54:09 +00:00
|
|
|
static inline bool IsCell(Mode mode) { return mode == CELL; }
|
2013-03-11 14:11:03 +00:00
|
|
|
static inline bool IsRuntimeEntry(Mode mode) {
|
|
|
|
return mode == RUNTIME_ENTRY;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
// Is the relocation mode affected by GC?
|
|
|
|
static inline bool IsGCRelocMode(Mode mode) {
|
|
|
|
return mode <= LAST_GCED_ENUM;
|
|
|
|
}
|
|
|
|
static inline bool IsJSReturn(Mode mode) {
|
|
|
|
return mode == JS_RETURN;
|
|
|
|
}
|
|
|
|
static inline bool IsComment(Mode mode) {
|
|
|
|
return mode == COMMENT;
|
|
|
|
}
|
2012-06-14 11:16:47 +00:00
|
|
|
static inline bool IsConstPool(Mode mode) {
|
|
|
|
return mode == CONST_POOL;
|
|
|
|
}
|
2014-03-12 15:40:41 +00:00
|
|
|
static inline bool IsVeneerPool(Mode mode) {
|
|
|
|
return mode == VENEER_POOL;
|
|
|
|
}
|
2015-02-11 17:11:23 +00:00
|
|
|
static inline bool IsDeoptReason(Mode mode) {
|
|
|
|
return mode == DEOPT_REASON;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
static inline bool IsPosition(Mode mode) {
|
|
|
|
return mode == POSITION || mode == STATEMENT_POSITION;
|
|
|
|
}
|
|
|
|
static inline bool IsStatementPosition(Mode mode) {
|
|
|
|
return mode == STATEMENT_POSITION;
|
|
|
|
}
|
|
|
|
static inline bool IsExternalReference(Mode mode) {
|
|
|
|
return mode == EXTERNAL_REFERENCE;
|
|
|
|
}
|
|
|
|
static inline bool IsInternalReference(Mode mode) {
|
|
|
|
return mode == INTERNAL_REFERENCE;
|
|
|
|
}
|
2015-02-17 14:52:16 +00:00
|
|
|
static inline bool IsInternalReferenceEncoded(Mode mode) {
|
|
|
|
return mode == INTERNAL_REFERENCE_ENCODED;
|
|
|
|
}
|
2010-06-08 12:04:49 +00:00
|
|
|
static inline bool IsDebugBreakSlot(Mode mode) {
|
|
|
|
return mode == DEBUG_BREAK_SLOT;
|
|
|
|
}
|
2015-03-04 13:15:07 +00:00
|
|
|
static inline bool IsDebuggerStatement(Mode mode) {
|
|
|
|
return mode == DEBUG_BREAK;
|
|
|
|
}
|
2012-12-28 13:34:15 +00:00
|
|
|
static inline bool IsNone(Mode mode) {
|
2013-01-04 10:56:24 +00:00
|
|
|
return mode == NONE32 || mode == NONE64;
|
2012-12-28 13:34:15 +00:00
|
|
|
}
|
2012-11-08 12:18:11 +00:00
|
|
|
static inline bool IsCodeAgeSequence(Mode mode) {
|
|
|
|
return mode == CODE_AGE_SEQUENCE;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
static inline int ModeMask(Mode mode) { return 1 << mode; }
|
|
|
|
|
2015-06-03 03:02:26 +00:00
|
|
|
// Returns true if the first RelocInfo has the same mode and raw data as the
|
|
|
|
// second one.
|
|
|
|
static inline bool IsEqual(RelocInfo first, RelocInfo second) {
|
|
|
|
return first.rmode() == second.rmode() &&
|
|
|
|
(first.rmode() == RelocInfo::NONE64 ?
|
|
|
|
first.raw_data64() == second.raw_data64() :
|
|
|
|
first.data() == second.data());
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Accessors
|
2010-09-24 08:25:31 +00:00
|
|
|
byte* pc() const { return pc_; }
|
2008-07-03 15:10:15 +00:00
|
|
|
void set_pc(byte* pc) { pc_ = pc; }
|
2008-09-22 13:57:03 +00:00
|
|
|
Mode rmode() const { return rmode_; }
|
2010-09-24 08:25:31 +00:00
|
|
|
intptr_t data() const { return data_; }
|
2015-06-03 03:02:26 +00:00
|
|
|
double data64() const { return data64_; }
|
|
|
|
uint64_t raw_data64() { return bit_cast<uint64_t>(data64_); }
|
2011-09-19 18:36:47 +00:00
|
|
|
Code* host() const { return host_; }
|
2014-03-12 17:18:49 +00:00
|
|
|
void set_host(Code* host) { host_ = host; }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Apply a relocation by delta bytes
|
2014-05-20 09:21:45 +00:00
|
|
|
INLINE(void apply(intptr_t delta,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-05-20 13:54:31 +00:00
|
|
|
// Is the pointer this relocation info refers to coded like a plain pointer
|
2012-01-16 12:38:59 +00:00
|
|
|
// or is it strange in some way (e.g. relative or patched into a series of
|
2010-05-20 13:54:31 +00:00
|
|
|
// instructions).
|
|
|
|
bool IsCodedSpecially();
|
|
|
|
|
2014-03-10 18:47:57 +00:00
|
|
|
// If true, the pointer this relocation info refers to is an entry in the
|
|
|
|
// constant pool, otherwise the pointer is embedded in the instruction stream.
|
|
|
|
bool IsInConstantPool();
|
|
|
|
|
2009-01-13 14:38:12 +00:00
|
|
|
// Read/modify the code target in the branch/call instruction
|
|
|
|
// this relocation applies to;
|
2013-03-13 11:40:26 +00:00
|
|
|
// can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
|
2008-07-03 15:10:15 +00:00
|
|
|
INLINE(Address target_address());
|
2011-10-21 10:37:56 +00:00
|
|
|
INLINE(void set_target_address(Address target,
|
2014-05-20 09:21:45 +00:00
|
|
|
WriteBarrierMode write_barrier_mode =
|
|
|
|
UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2008-07-03 15:10:15 +00:00
|
|
|
INLINE(Object* target_object());
|
2009-10-06 13:11:05 +00:00
|
|
|
INLINE(Handle<Object> target_object_handle(Assembler* origin));
|
2011-10-21 10:37:56 +00:00
|
|
|
INLINE(void set_target_object(Object* target,
|
2014-05-20 09:21:45 +00:00
|
|
|
WriteBarrierMode write_barrier_mode =
|
|
|
|
UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2013-03-11 14:11:03 +00:00
|
|
|
INLINE(Address target_runtime_entry(Assembler* origin));
|
|
|
|
INLINE(void set_target_runtime_entry(Address target,
|
2014-05-20 09:21:45 +00:00
|
|
|
WriteBarrierMode write_barrier_mode =
|
|
|
|
UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2013-06-12 15:03:44 +00:00
|
|
|
INLINE(Cell* target_cell());
|
|
|
|
INLINE(Handle<Cell> target_cell_handle());
|
|
|
|
INLINE(void set_target_cell(Cell* cell,
|
2014-05-20 09:21:45 +00:00
|
|
|
WriteBarrierMode write_barrier_mode =
|
|
|
|
UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2013-10-23 13:48:04 +00:00
|
|
|
INLINE(Handle<Object> code_age_stub_handle(Assembler* origin));
|
2012-11-08 12:18:11 +00:00
|
|
|
INLINE(Code* code_age_stub());
|
2014-05-20 09:21:45 +00:00
|
|
|
INLINE(void set_code_age_stub(Code* stub,
|
|
|
|
ICacheFlushMode icache_flush_mode =
|
|
|
|
FLUSH_ICACHE_IF_NEEDED));
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-03-10 18:47:57 +00:00
|
|
|
// Returns the address of the constant pool entry where the target address
|
|
|
|
// is held. This should only be called if IsInConstantPool returns true.
|
|
|
|
INLINE(Address constant_pool_entry_address());
|
|
|
|
|
2010-05-26 08:34:07 +00:00
|
|
|
// Read the address of the word containing the target_address in an
|
|
|
|
// instruction stream. What this means exactly is architecture-independent.
|
|
|
|
// The only architecture-independent user of this function is the serializer.
|
|
|
|
// The serializer uses it to find out how many raw bytes of instruction to
|
|
|
|
// output before the next target. Architecture-independent code shouldn't
|
|
|
|
// dereference the pointer it gets back from this.
|
2009-01-13 14:38:12 +00:00
|
|
|
INLINE(Address target_address_address());
|
2014-03-10 18:47:57 +00:00
|
|
|
|
2010-05-26 08:34:07 +00:00
|
|
|
// This indicates how much space a target takes up when deserializing a code
|
|
|
|
// stream. For most architectures this is just the size of a pointer. For
|
|
|
|
// an instruction like movw/movt where the target bits are mixed into the
|
|
|
|
// instruction bits the size of the target will be zero, indicating that the
|
|
|
|
// serializer should not step forwards in memory after a target is resolved
|
|
|
|
// and written. In this case the target_address_address function above
|
|
|
|
// should return the end of the instructions to be patched, allowing the
|
|
|
|
// deserializer to deserialize the instructions as raw bytes and put them in
|
|
|
|
// place, ready to be patched with the target.
|
|
|
|
INLINE(int target_address_size());
|
2009-01-13 14:38:12 +00:00
|
|
|
|
2015-03-05 13:46:31 +00:00
|
|
|
// Read the reference in the instruction this relocation
|
|
|
|
// applies to; can only be called if rmode_ is EXTERNAL_REFERENCE.
|
|
|
|
INLINE(Address target_external_reference());
|
|
|
|
|
2015-03-18 13:38:32 +00:00
|
|
|
// Read the reference in the instruction this relocation
|
2015-03-05 13:46:31 +00:00
|
|
|
// applies to; can only be called if rmode_ is INTERNAL_REFERENCE.
|
|
|
|
INLINE(Address target_internal_reference());
|
2015-03-18 13:38:32 +00:00
|
|
|
|
|
|
|
// Return the reference address this relocation applies to;
|
|
|
|
// can only be called if rmode_ is INTERNAL_REFERENCE.
|
|
|
|
INLINE(Address target_internal_reference_address());
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Read/modify the address of a call instruction. This is used to relocate
|
|
|
|
// the break points where straight-line code is patched with a call
|
|
|
|
// instruction.
|
|
|
|
INLINE(Address call_address());
|
|
|
|
INLINE(void set_call_address(Address target));
|
|
|
|
INLINE(Object* call_object());
|
|
|
|
INLINE(void set_call_object(Object* target));
|
2010-08-05 13:38:27 +00:00
|
|
|
INLINE(Object** call_object_address());
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-11-05 10:14:48 +00:00
|
|
|
// Wipe out a relocation to a fixed value, used for making snapshots
|
|
|
|
// reproducible.
|
|
|
|
INLINE(void WipeOut());
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
template<typename StaticVisitor> inline void Visit(Heap* heap);
|
2013-09-11 10:51:06 +00:00
|
|
|
inline void Visit(Isolate* isolate, ObjectVisitor* v);
|
2010-05-26 08:34:07 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Patch the code with a call.
|
2009-02-09 12:17:39 +00:00
|
|
|
void PatchCodeWithCall(Address target, int guard_bytes);
|
2009-10-15 11:52:53 +00:00
|
|
|
|
|
|
|
// Check whether this return sequence has been patched
|
|
|
|
// with a call to the debugger.
|
|
|
|
INLINE(bool IsPatchedReturnSequence());
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-06-08 12:04:49 +00:00
|
|
|
// Check whether this debug break slot has been patched with a call to the
|
|
|
|
// debugger.
|
|
|
|
INLINE(bool IsPatchedDebugBreakSlotSequence());
|
|
|
|
|
2013-02-20 13:12:26 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Check whether the given code contains relocation information that
|
|
|
|
// either is position-relative or movable by the garbage collector.
|
|
|
|
static bool RequiresRelocation(const CodeDesc& desc);
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 10:02:49 +00:00
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
|
|
// Printing
|
2008-09-22 13:57:03 +00:00
|
|
|
static const char* RelocModeName(Mode rmode);
|
2014-09-30 10:29:32 +00:00
|
|
|
void Print(Isolate* isolate, std::ostream& os); // NOLINT
|
2008-08-06 10:02:49 +00:00
|
|
|
#endif // ENABLE_DISASSEMBLER
|
2012-10-12 11:41:14 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2014-05-06 11:25:37 +00:00
|
|
|
void Verify(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
|
|
|
|
static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
|
2011-04-27 15:02:59 +00:00
|
|
|
static const int kDataMask =
|
|
|
|
(1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT);
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kApplyMask; // Modes affected by apply. Depends on arch.
|
|
|
|
|
|
|
|
private:
|
|
|
|
// On ARM, note that pc_ is the address of the constant pool entry
|
|
|
|
// to be relocated and not the address of the instruction
|
|
|
|
// referencing the constant pool entry (except when rmode_ ==
|
|
|
|
// comment).
|
|
|
|
byte* pc_;
|
2008-09-22 13:57:03 +00:00
|
|
|
Mode rmode_;
|
2015-06-03 03:02:26 +00:00
|
|
|
union {
|
|
|
|
intptr_t data_;
|
|
|
|
double data64_;
|
|
|
|
};
|
2011-09-19 18:36:47 +00:00
|
|
|
Code* host_;
|
2011-05-24 07:56:20 +00:00
|
|
|
// External-reference pointers are also split across instruction-pairs
|
2012-10-18 12:21:42 +00:00
|
|
|
// on some platforms, but are accessed via indirect pointers. This location
|
2011-05-24 07:56:20 +00:00
|
|
|
// provides a place for that pointer to exist naturally. Its address
|
|
|
|
// is returned by RelocInfo::target_reference_address().
|
|
|
|
Address reconstructed_adr_ptr_;
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class RelocIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// RelocInfoWriter serializes a stream of relocation info. It writes towards
|
|
|
|
// lower addresses.
|
|
|
|
class RelocInfoWriter BASE_EMBEDDED {
|
|
|
|
public:
|
2015-02-12 12:15:14 +00:00
|
|
|
RelocInfoWriter()
|
|
|
|
: pos_(NULL),
|
|
|
|
last_pc_(NULL),
|
|
|
|
last_id_(0),
|
|
|
|
last_position_(0),
|
|
|
|
last_mode_(RelocInfo::NUMBER_OF_MODES),
|
|
|
|
next_position_candidate_pos_delta_(0),
|
|
|
|
next_position_candidate_pc_delta_(0),
|
|
|
|
next_position_candidate_flushed_(true) {}
|
|
|
|
RelocInfoWriter(byte* pos, byte* pc)
|
|
|
|
: pos_(pos),
|
|
|
|
last_pc_(pc),
|
|
|
|
last_id_(0),
|
|
|
|
last_position_(0),
|
|
|
|
last_mode_(RelocInfo::NUMBER_OF_MODES),
|
|
|
|
next_position_candidate_pos_delta_(0),
|
|
|
|
next_position_candidate_pc_delta_(0),
|
|
|
|
next_position_candidate_flushed_(true) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
byte* pos() const { return pos_; }
|
|
|
|
byte* last_pc() const { return last_pc_; }
|
|
|
|
|
|
|
|
void Write(const RelocInfo* rinfo);
|
|
|
|
|
|
|
|
// Update the state of the stream after reloc info buffer
|
|
|
|
// and/or code is moved while the stream is active.
|
|
|
|
void Reposition(byte* pos, byte* pc) {
|
|
|
|
pos_ = pos;
|
|
|
|
last_pc_ = pc;
|
|
|
|
}
|
|
|
|
|
2015-02-12 12:15:14 +00:00
|
|
|
void Finish() { FlushPosition(); }
|
|
|
|
|
2009-06-23 09:50:51 +00:00
|
|
|
// Max size (bytes) of a written RelocInfo. Longest encoding is
|
|
|
|
// ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta.
|
|
|
|
// On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12.
|
|
|
|
// On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16;
|
|
|
|
// Here we use the maximum of the two.
|
|
|
|
static const int kMaxSize = 16;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
|
|
|
|
inline void WriteTaggedPC(uint32_t pc_delta, int tag);
|
|
|
|
inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag);
|
2011-04-27 15:02:59 +00:00
|
|
|
inline void WriteExtraTaggedIntData(int data_delta, int top_tag);
|
2014-03-12 15:40:41 +00:00
|
|
|
inline void WriteExtraTaggedPoolData(int data, int pool_type);
|
2009-05-29 12:14:54 +00:00
|
|
|
inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag);
|
|
|
|
inline void WriteTaggedData(intptr_t data_delta, int tag);
|
2008-07-03 15:10:15 +00:00
|
|
|
inline void WriteExtraTag(int extra_tag, int top_tag);
|
2015-02-12 12:15:14 +00:00
|
|
|
inline void WritePosition(int pc_delta, int pos_delta, RelocInfo::Mode rmode);
|
|
|
|
|
|
|
|
void FlushPosition();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
byte* pos_;
|
|
|
|
byte* last_pc_;
|
2011-04-27 15:02:59 +00:00
|
|
|
int last_id_;
|
|
|
|
int last_position_;
|
2015-02-12 12:15:14 +00:00
|
|
|
RelocInfo::Mode last_mode_;
|
|
|
|
int next_position_candidate_pos_delta_;
|
|
|
|
uint32_t next_position_candidate_pc_delta_;
|
|
|
|
bool next_position_candidate_flushed_;
|
|
|
|
|
2008-08-28 09:55:41 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// A RelocIterator iterates over relocation information.
|
|
|
|
// Typical use:
|
|
|
|
//
|
|
|
|
// for (RelocIterator it(code); !it.done(); it.next()) {
|
|
|
|
// // do something with it.rinfo() here
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// A mask can be specified to skip unwanted modes.
|
|
|
|
class RelocIterator: public Malloced {
|
|
|
|
public:
|
|
|
|
// Create a new iterator positioned at
|
|
|
|
// the beginning of the reloc info.
|
|
|
|
// Relocation information with mode k is included in the
|
|
|
|
// iteration iff bit k of mode_mask is set.
|
|
|
|
explicit RelocIterator(Code* code, int mode_mask = -1);
|
|
|
|
explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1);
|
|
|
|
|
|
|
|
// Iteration
|
2010-09-24 08:25:31 +00:00
|
|
|
bool done() const { return done_; }
|
2008-07-03 15:10:15 +00:00
|
|
|
void next();
|
|
|
|
|
|
|
|
// Return pointer valid until next next().
|
|
|
|
RelocInfo* rinfo() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!done());
|
2008-07-03 15:10:15 +00:00
|
|
|
return &rinfo_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Advance* moves the position before/after reading.
|
|
|
|
// *Read* reads from current byte(s) into rinfo_.
|
|
|
|
// *Get* just reads and returns info on current byte.
|
|
|
|
void Advance(int bytes = 1) { pos_ -= bytes; }
|
|
|
|
int AdvanceGetTag();
|
|
|
|
int GetExtraTag();
|
|
|
|
int GetTopTag();
|
|
|
|
void ReadTaggedPC();
|
|
|
|
void AdvanceReadPC();
|
2011-04-27 15:02:59 +00:00
|
|
|
void AdvanceReadId();
|
2014-03-12 15:40:41 +00:00
|
|
|
void AdvanceReadPoolData();
|
2011-04-27 15:02:59 +00:00
|
|
|
void AdvanceReadPosition();
|
2008-07-03 15:10:15 +00:00
|
|
|
void AdvanceReadData();
|
|
|
|
void AdvanceReadVariableLengthPCJump();
|
2011-04-27 15:02:59 +00:00
|
|
|
int GetLocatableTypeTag();
|
|
|
|
void ReadTaggedId();
|
|
|
|
void ReadTaggedPosition();
|
2015-02-05 14:51:45 +00:00
|
|
|
void ReadTaggedData();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// If the given mode is wanted, set it in rinfo_ and return true.
|
|
|
|
// Else return false. Used for efficiently skipping unwanted modes.
|
2008-09-22 13:57:03 +00:00
|
|
|
bool SetMode(RelocInfo::Mode mode) {
|
2010-11-30 10:55:24 +00:00
|
|
|
return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
byte* pos_;
|
|
|
|
byte* end_;
|
2012-11-08 12:18:11 +00:00
|
|
|
byte* code_age_sequence_;
|
2008-07-03 15:10:15 +00:00
|
|
|
RelocInfo rinfo_;
|
|
|
|
bool done_;
|
|
|
|
int mode_mask_;
|
2011-04-27 15:02:59 +00:00
|
|
|
int last_id_;
|
|
|
|
int last_position_;
|
2008-08-28 09:55:41 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(RelocIterator);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// External function
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class IC_Utility;
|
|
|
|
class SCTableReference;
|
2009-04-20 16:36:13 +00:00
|
|
|
class Debug_Address;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-06-09 09:26:53 +00:00
|
|
|
|
|
|
|
// An ExternalReference represents a C++ address used in the generated
|
|
|
|
// code. All references to C++ functions and variables must be encapsulated in
|
|
|
|
// an ExternalReference instance. This is done in order to track the origin of
|
|
|
|
// all external references in the code so that they can be bound to the correct
|
|
|
|
// addresses when deserializing a heap.
|
2008-07-03 15:10:15 +00:00
|
|
|
class ExternalReference BASE_EMBEDDED {
|
|
|
|
public:
|
2011-02-04 13:43:38 +00:00
|
|
|
// Used in the simulator to support different native api calls.
|
|
|
|
enum Type {
|
2011-02-24 15:39:09 +00:00
|
|
|
// Builtin call.
|
2014-04-30 12:25:18 +00:00
|
|
|
// Object* f(v8::internal::Arguments).
|
2011-02-04 13:43:38 +00:00
|
|
|
BUILTIN_CALL, // default
|
2011-02-24 15:39:09 +00:00
|
|
|
|
2011-04-27 14:29:25 +00:00
|
|
|
// Builtin that takes float arguments and returns an int.
|
|
|
|
// int f(double, double).
|
|
|
|
BUILTIN_COMPARE_CALL,
|
|
|
|
|
2011-02-24 15:39:09 +00:00
|
|
|
// Builtin call that returns floating point.
|
|
|
|
// double f(double, double).
|
2011-04-27 14:29:25 +00:00
|
|
|
BUILTIN_FP_FP_CALL,
|
|
|
|
|
|
|
|
// Builtin call that returns floating point.
|
|
|
|
// double f(double).
|
|
|
|
BUILTIN_FP_CALL,
|
|
|
|
|
|
|
|
// Builtin call that returns floating point.
|
|
|
|
// double f(double, int).
|
|
|
|
BUILTIN_FP_INT_CALL,
|
2011-02-24 15:39:09 +00:00
|
|
|
|
|
|
|
// Direct call to API function callback.
|
2013-08-27 13:41:44 +00:00
|
|
|
// void f(v8::FunctionCallbackInfo&)
|
2011-02-24 15:39:09 +00:00
|
|
|
DIRECT_API_CALL,
|
|
|
|
|
2013-06-13 19:16:35 +00:00
|
|
|
// Call to function callback via InvokeFunctionCallback.
|
2013-08-27 13:41:44 +00:00
|
|
|
// void f(v8::FunctionCallbackInfo&, v8::FunctionCallback)
|
|
|
|
PROFILING_API_CALL,
|
2013-06-13 19:16:35 +00:00
|
|
|
|
2011-02-24 15:39:09 +00:00
|
|
|
// Direct call to accessor getter callback.
|
2014-08-20 15:25:13 +00:00
|
|
|
// void f(Local<Name> property, PropertyCallbackInfo& info)
|
2013-05-21 12:17:04 +00:00
|
|
|
DIRECT_GETTER_CALL,
|
|
|
|
|
2013-06-13 19:16:35 +00:00
|
|
|
// Call to accessor getter callback via InvokeAccessorGetterCallback.
|
2014-08-20 15:25:13 +00:00
|
|
|
// void f(Local<Name> property, PropertyCallbackInfo& info,
|
|
|
|
// AccessorNameGetterCallback callback)
|
2013-08-27 13:41:44 +00:00
|
|
|
PROFILING_GETTER_CALL
|
2011-02-04 13:43:38 +00:00
|
|
|
};
|
|
|
|
|
2012-04-05 14:10:39 +00:00
|
|
|
static void SetUp();
|
2012-11-26 13:12:35 +00:00
|
|
|
static void InitializeMathExpData();
|
|
|
|
static void TearDownMathExpData();
|
2012-04-05 14:10:39 +00:00
|
|
|
|
2011-02-04 13:43:38 +00:00
|
|
|
typedef void* ExternalReferenceRedirector(void* original, Type type);
|
|
|
|
|
2013-07-29 13:56:51 +00:00
|
|
|
ExternalReference() : address_(NULL) {}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(Builtins::CFunctionId id, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(ApiFunction* ptr, Type type, Isolate* isolate);
|
2009-11-04 08:51:48 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(Builtins::Name name, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(Runtime::FunctionId id, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(const Runtime::Function* f, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(const IC_Utility& ic_utility, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
explicit ExternalReference(StatsCounter* counter);
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(Isolate::AddressId id, Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
explicit ExternalReference(const SCTableReference& table_ref);
|
|
|
|
|
2013-09-02 09:27:27 +00:00
|
|
|
// Isolate as an external reference.
|
2013-04-24 07:39:35 +00:00
|
|
|
static ExternalReference isolate_address(Isolate* isolate);
|
2011-03-18 20:35:07 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// One-of-a-kind references. These references are not part of a general
|
|
|
|
// pattern. This means that they have to be added to the
|
|
|
|
// ExternalReferenceTable in serialize.cc manually.
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
static ExternalReference incremental_marking_record_write_function(
|
|
|
|
Isolate* isolate);
|
|
|
|
static ExternalReference store_buffer_overflow_function(
|
|
|
|
Isolate* isolate);
|
2011-09-16 09:23:48 +00:00
|
|
|
static ExternalReference flush_icache_function(Isolate* isolate);
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference delete_handle_scope_extensions(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-03-09 12:07:29 +00:00
|
|
|
static ExternalReference get_date_field_function(Isolate* isolate);
|
|
|
|
static ExternalReference date_cache_stamp(Isolate* isolate);
|
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
static ExternalReference get_make_code_young_function(Isolate* isolate);
|
2013-10-23 13:48:04 +00:00
|
|
|
static ExternalReference get_mark_code_as_executed_function(Isolate* isolate);
|
2012-11-08 12:18:11 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Deoptimization support.
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference new_deoptimizer_function(Isolate* isolate);
|
|
|
|
static ExternalReference compute_output_frames_function(Isolate* isolate);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-11-28 15:11:21 +00:00
|
|
|
// Log support.
|
|
|
|
static ExternalReference log_enter_external_function(Isolate* isolate);
|
|
|
|
static ExternalReference log_leave_external_function(Isolate* isolate);
|
|
|
|
|
2009-12-10 15:10:50 +00:00
|
|
|
// Static data in the keyed lookup cache.
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference keyed_lookup_cache_keys(Isolate* isolate);
|
|
|
|
static ExternalReference keyed_lookup_cache_field_offsets(Isolate* isolate);
|
2009-12-10 15:10:50 +00:00
|
|
|
|
2011-10-20 12:27:10 +00:00
|
|
|
// Static variable Heap::roots_array_start()
|
|
|
|
static ExternalReference roots_array_start(Isolate* isolate);
|
2009-08-24 11:57:57 +00:00
|
|
|
|
2013-07-17 11:50:24 +00:00
|
|
|
// Static variable Heap::allocation_sites_list_address()
|
|
|
|
static ExternalReference allocation_sites_list_address(Isolate* isolate);
|
|
|
|
|
2009-02-12 09:29:02 +00:00
|
|
|
// Static variable StackGuard::address_of_jslimit()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference address_of_stack_limit(Isolate* isolate);
|
2009-11-05 13:59:40 +00:00
|
|
|
|
|
|
|
// Static variable StackGuard::address_of_real_jslimit()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference address_of_real_stack_limit(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-01-12 13:05:23 +00:00
|
|
|
// Static variable RegExpStack::limit_address()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference address_of_regexp_stack_limit(Isolate* isolate);
|
2009-01-12 13:05:23 +00:00
|
|
|
|
2010-01-06 11:09:30 +00:00
|
|
|
// Static variables for RegExp.
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference address_of_static_offsets_vector(Isolate* isolate);
|
|
|
|
static ExternalReference address_of_regexp_stack_memory_address(
|
|
|
|
Isolate* isolate);
|
|
|
|
static ExternalReference address_of_regexp_stack_memory_size(
|
|
|
|
Isolate* isolate);
|
2010-01-06 11:09:30 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Static variable Heap::NewSpaceStart()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference new_space_start(Isolate* isolate);
|
|
|
|
static ExternalReference new_space_mask(Isolate* isolate);
|
2011-09-19 18:36:47 +00:00
|
|
|
|
|
|
|
// Write barrier.
|
|
|
|
static ExternalReference store_buffer_top(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Used for fast allocation in generated code.
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference new_space_allocation_top_address(Isolate* isolate);
|
|
|
|
static ExternalReference new_space_allocation_limit_address(Isolate* isolate);
|
2015-04-07 11:31:57 +00:00
|
|
|
static ExternalReference old_space_allocation_top_address(Isolate* isolate);
|
|
|
|
static ExternalReference old_space_allocation_limit_address(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-12-18 10:40:26 +00:00
|
|
|
static ExternalReference mod_two_doubles_operation(Isolate* isolate);
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference power_double_double_function(Isolate* isolate);
|
|
|
|
static ExternalReference power_double_int_function(Isolate* isolate);
|
2009-04-16 09:30:23 +00:00
|
|
|
|
2013-02-25 14:46:09 +00:00
|
|
|
static ExternalReference handle_scope_next_address(Isolate* isolate);
|
|
|
|
static ExternalReference handle_scope_limit_address(Isolate* isolate);
|
|
|
|
static ExternalReference handle_scope_level_address(Isolate* isolate);
|
2009-11-04 08:51:48 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference scheduled_exception_address(Isolate* isolate);
|
2012-06-11 13:18:05 +00:00
|
|
|
static ExternalReference address_of_pending_message_obj(Isolate* isolate);
|
2009-11-04 08:51:48 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Static variables containing common double constants.
|
|
|
|
static ExternalReference address_of_min_int();
|
|
|
|
static ExternalReference address_of_one_half();
|
2013-02-27 14:44:57 +00:00
|
|
|
static ExternalReference address_of_minus_one_half();
|
2010-12-08 14:32:40 +00:00
|
|
|
static ExternalReference address_of_negative_infinity();
|
2011-07-13 13:50:27 +00:00
|
|
|
static ExternalReference address_of_the_hole_nan();
|
2013-10-15 16:12:25 +00:00
|
|
|
static ExternalReference address_of_uint32_bias();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference math_log_double_function(Isolate* isolate);
|
2011-03-02 14:40:38 +00:00
|
|
|
|
2012-11-26 13:12:35 +00:00
|
|
|
static ExternalReference math_exp_constants(int constant_index);
|
|
|
|
static ExternalReference math_exp_log_table();
|
|
|
|
|
2012-06-06 11:05:28 +00:00
|
|
|
static ExternalReference page_flags(Page* page);
|
|
|
|
|
2012-12-18 16:25:45 +00:00
|
|
|
static ExternalReference ForDeoptEntry(Address entry);
|
|
|
|
|
2013-01-23 16:29:48 +00:00
|
|
|
static ExternalReference cpu_features();
|
|
|
|
|
2014-06-23 07:10:25 +00:00
|
|
|
static ExternalReference debug_is_active_address(Isolate* isolate);
|
2014-05-22 07:57:33 +00:00
|
|
|
static ExternalReference debug_after_break_target_address(Isolate* isolate);
|
|
|
|
static ExternalReference debug_restarter_frame_function_pointer_address(
|
|
|
|
Isolate* isolate);
|
|
|
|
|
2014-04-28 08:26:35 +00:00
|
|
|
static ExternalReference is_profiling_address(Isolate* isolate);
|
|
|
|
static ExternalReference invoke_function_callback(Isolate* isolate);
|
|
|
|
static ExternalReference invoke_accessor_getter_callback(Isolate* isolate);
|
|
|
|
|
2013-07-29 13:56:51 +00:00
|
|
|
Address address() const { return reinterpret_cast<Address>(address_); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
// Function Debug::Break()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference debug_break(Isolate* isolate);
|
2009-04-20 16:36:13 +00:00
|
|
|
|
|
|
|
// Used to check if single stepping is enabled in generated code.
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference debug_step_in_fp_address(Isolate* isolate);
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2010-04-19 19:30:11 +00:00
|
|
|
#ifndef V8_INTERPRETED_REGEXP
|
2009-08-31 12:40:37 +00:00
|
|
|
// C functions called from RegExp generated code.
|
|
|
|
|
|
|
|
// Function NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference re_case_insensitive_compare_uc16(Isolate* isolate);
|
2009-08-31 12:40:37 +00:00
|
|
|
|
|
|
|
// Function RegExpMacroAssembler*::CheckStackGuardState()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference re_check_stack_guard_state(Isolate* isolate);
|
2009-08-31 12:40:37 +00:00
|
|
|
|
|
|
|
// Function NativeRegExpMacroAssembler::GrowStack()
|
2011-03-22 13:20:04 +00:00
|
|
|
static ExternalReference re_grow_stack(Isolate* isolate);
|
2010-01-18 09:49:50 +00:00
|
|
|
|
|
|
|
// byte NativeRegExpMacroAssembler::word_character_bitmap
|
|
|
|
static ExternalReference re_word_character_map();
|
|
|
|
|
2009-08-31 12:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
2009-06-09 09:26:53 +00:00
|
|
|
// This lets you register a function that rewrites all external references.
|
|
|
|
// Used by the ARM simulator to catch calls to external references.
|
2011-05-05 18:55:31 +00:00
|
|
|
static void set_redirector(Isolate* isolate,
|
|
|
|
ExternalReferenceRedirector* redirector) {
|
2011-03-18 20:35:07 +00:00
|
|
|
// We can't stack them.
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate->external_reference_redirector() == NULL);
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate->set_external_reference_redirector(
|
2011-03-18 20:35:07 +00:00
|
|
|
reinterpret_cast<ExternalReferenceRedirectorPointer*>(redirector));
|
2009-06-09 09:26:53 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 08:12:01 +00:00
|
|
|
static ExternalReference stress_deopt_count(Isolate* isolate);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
explicit ExternalReference(void* address)
|
2009-06-09 09:26:53 +00:00
|
|
|
: address_(address) {}
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
static void* Redirect(Isolate* isolate,
|
|
|
|
Address address_arg,
|
2011-02-04 13:43:38 +00:00
|
|
|
Type type = ExternalReference::BUILTIN_CALL) {
|
2011-03-18 20:35:07 +00:00
|
|
|
ExternalReferenceRedirector* redirector =
|
|
|
|
reinterpret_cast<ExternalReferenceRedirector*>(
|
2011-03-22 13:20:04 +00:00
|
|
|
isolate->external_reference_redirector());
|
2009-06-09 09:26:53 +00:00
|
|
|
void* address = reinterpret_cast<void*>(address_arg);
|
2011-03-18 20:35:07 +00:00
|
|
|
void* answer = (redirector == NULL) ?
|
2009-11-16 12:08:40 +00:00
|
|
|
address :
|
2011-03-18 20:35:07 +00:00
|
|
|
(*redirector)(address, type);
|
2009-11-16 12:08:40 +00:00
|
|
|
return answer;
|
2009-06-09 09:26:53 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-06-09 09:26:53 +00:00
|
|
|
void* address_;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2014-10-07 13:30:28 +00:00
|
|
|
bool operator==(ExternalReference, ExternalReference);
|
|
|
|
bool operator!=(ExternalReference, ExternalReference);
|
|
|
|
|
|
|
|
size_t hash_value(ExternalReference);
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream&, ExternalReference);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-11-04 15:12:03 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Position recording support
|
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
struct PositionState {
|
|
|
|
PositionState() : current_position(RelocInfo::kNoPosition),
|
|
|
|
written_position(RelocInfo::kNoPosition),
|
|
|
|
current_statement_position(RelocInfo::kNoPosition),
|
|
|
|
written_statement_position(RelocInfo::kNoPosition) {}
|
|
|
|
|
|
|
|
int current_position;
|
|
|
|
int written_position;
|
|
|
|
|
|
|
|
int current_statement_position;
|
|
|
|
int written_statement_position;
|
|
|
|
};
|
|
|
|
|
2010-11-04 15:12:03 +00:00
|
|
|
|
|
|
|
class PositionsRecorder BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
explicit PositionsRecorder(Assembler* assembler)
|
2011-01-18 16:11:01 +00:00
|
|
|
: assembler_(assembler) {
|
2013-02-18 18:06:12 +00:00
|
|
|
jit_handler_data_ = NULL;
|
2011-01-18 16:11:01 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 18:06:12 +00:00
|
|
|
void AttachJITHandlerData(void* user_data) {
|
|
|
|
jit_handler_data_ = user_data;
|
|
|
|
}
|
2010-11-30 13:17:36 +00:00
|
|
|
|
2013-02-18 18:06:12 +00:00
|
|
|
void* DetachJITHandlerData() {
|
|
|
|
void* old_data = jit_handler_data_;
|
|
|
|
jit_handler_data_ = NULL;
|
|
|
|
return old_data;
|
|
|
|
}
|
2010-11-30 13:17:36 +00:00
|
|
|
// Set current position to pos.
|
|
|
|
void RecordPosition(int pos);
|
2010-11-04 15:12:03 +00:00
|
|
|
|
|
|
|
// Set current statement position to pos.
|
|
|
|
void RecordStatementPosition(int pos);
|
|
|
|
|
|
|
|
// Write recorded positions to relocation information.
|
|
|
|
bool WriteRecordedPositions();
|
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
int current_position() const { return state_.current_position; }
|
2010-11-04 15:12:03 +00:00
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
int current_statement_position() const {
|
|
|
|
return state_.current_statement_position;
|
|
|
|
}
|
2010-11-04 15:12:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Assembler* assembler_;
|
2010-11-30 13:17:36 +00:00
|
|
|
PositionState state_;
|
2010-11-04 15:12:03 +00:00
|
|
|
|
2013-02-18 18:06:12 +00:00
|
|
|
// Currently jit_handler_data_ is used to store JITHandler-specific data
|
|
|
|
// over the lifetime of a PositionsRecorder
|
|
|
|
void* jit_handler_data_;
|
2010-11-30 13:17:36 +00:00
|
|
|
friend class PreservePositionScope;
|
2010-11-04 15:12:03 +00:00
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(PositionsRecorder);
|
2010-11-04 15:12:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
class PreservePositionScope BASE_EMBEDDED {
|
2010-11-04 15:12:03 +00:00
|
|
|
public:
|
2010-11-30 13:17:36 +00:00
|
|
|
explicit PreservePositionScope(PositionsRecorder* positions_recorder)
|
2010-11-04 15:12:03 +00:00
|
|
|
: positions_recorder_(positions_recorder),
|
2015-05-29 12:56:26 +00:00
|
|
|
saved_state_(positions_recorder->state_) {
|
|
|
|
// Reset positions so that previous ones do not accidentally get
|
|
|
|
// recorded within this scope.
|
|
|
|
positions_recorder->state_ = PositionState();
|
|
|
|
}
|
2010-11-04 15:12:03 +00:00
|
|
|
|
2010-11-30 13:17:36 +00:00
|
|
|
~PreservePositionScope() {
|
|
|
|
positions_recorder_->state_ = saved_state_;
|
2010-11-04 15:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PositionsRecorder* positions_recorder_;
|
2010-11-30 13:17:36 +00:00
|
|
|
const PositionState saved_state_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PreservePositionScope);
|
2010-11-04 15:12:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Utility functions
|
|
|
|
|
2011-11-29 10:56:11 +00:00
|
|
|
inline int NumberOfBitsSet(uint32_t x) {
|
2010-02-04 20:36:58 +00:00
|
|
|
unsigned int num_bits_set;
|
|
|
|
for (num_bits_set = 0; x; x >>= 1) {
|
|
|
|
num_bits_set += x & 1;
|
|
|
|
}
|
|
|
|
return num_bits_set;
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-10-20 10:26:45 +00:00
|
|
|
bool EvalComparison(Token::Value op, double op1, double op2);
|
|
|
|
|
2010-12-08 14:32:40 +00:00
|
|
|
// Computes pow(x, y) with the special cases in the spec for Math.pow.
|
2013-02-21 11:40:37 +00:00
|
|
|
double power_helper(double x, double y);
|
2010-12-08 14:32:40 +00:00
|
|
|
double power_double_int(double x, int y);
|
|
|
|
double power_double_double(double x, double y);
|
|
|
|
|
2011-05-03 09:30:06 +00:00
|
|
|
// Helper class for generating code or data associated with the code
|
|
|
|
// right after a call instruction. As an example this can be used to
|
|
|
|
// generate safepoint data after calls for crankshaft.
|
|
|
|
class CallWrapper {
|
|
|
|
public:
|
|
|
|
CallWrapper() { }
|
|
|
|
virtual ~CallWrapper() { }
|
|
|
|
// Called just before emitting a call. Argument is the size of the generated
|
|
|
|
// call code.
|
2011-05-03 15:12:40 +00:00
|
|
|
virtual void BeforeCall(int call_size) const = 0;
|
2011-05-03 09:30:06 +00:00
|
|
|
// Called just after emitting a call, i.e., at the return site for the call.
|
2011-05-03 15:12:40 +00:00
|
|
|
virtual void AfterCall() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NullCallWrapper : public CallWrapper {
|
|
|
|
public:
|
|
|
|
NullCallWrapper() { }
|
|
|
|
virtual ~NullCallWrapper() { }
|
|
|
|
virtual void BeforeCall(int call_size) const { }
|
|
|
|
virtual void AfterCall() const { }
|
2011-05-03 09:30:06 +00:00
|
|
|
};
|
|
|
|
|
2014-03-10 10:39:17 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_ASSEMBLER_H_
|