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_
|
|
|
|
|
2017-05-31 14:00:11 +00:00
|
|
|
#include <forward_list>
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
2016-07-14 06:26:03 +00:00
|
|
|
#include "src/builtins/builtins.h"
|
2016-07-18 09:23:28 +00:00
|
|
|
#include "src/deoptimize-reason.h"
|
2017-07-05 13:48:12 +00:00
|
|
|
#include "src/double.h"
|
2016-10-17 10:01:42 +00:00
|
|
|
#include "src/globals.h"
|
2017-01-20 14:21:34 +00:00
|
|
|
#include "src/label.h"
|
2016-03-02 02:10:03 +00:00
|
|
|
#include "src/log.h"
|
2016-06-24 08:23:52 +00:00
|
|
|
#include "src/register-configuration.h"
|
2017-08-01 13:38:20 +00:00
|
|
|
#include "src/reglist.h"
|
2014-09-25 07:16:15 +00:00
|
|
|
#include "src/runtime/runtime.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
|
|
|
|
2015-08-12 07:32:36 +00:00
|
|
|
// Forward declarations.
|
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
|
|
|
|
2015-08-12 07:32:36 +00:00
|
|
|
// Forward declarations.
|
2017-06-23 12:21:39 +00:00
|
|
|
class Isolate;
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
class SourcePosition;
|
2013-04-24 14:05:37 +00:00
|
|
|
class StatsCounter;
|
2015-08-12 07:32:36 +00:00
|
|
|
|
2017-08-01 13:38:20 +00:00
|
|
|
void SetUpJSCallerSavedCodeData();
|
|
|
|
|
|
|
|
// Return the code of the n-th saved register available to JavaScript.
|
|
|
|
int JSCallerSavedCode(int n);
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Platform independent assembler base class.
|
|
|
|
|
2015-11-25 14:23:37 +00:00
|
|
|
enum class CodeObjectRequired { kNo, kYes };
|
|
|
|
|
|
|
|
|
2011-03-22 13:20:04 +00:00
|
|
|
class AssemblerBase: public Malloced {
|
|
|
|
public:
|
2017-03-17 11:18:06 +00:00
|
|
|
struct IsolateData {
|
|
|
|
explicit IsolateData(Isolate* isolate);
|
|
|
|
IsolateData(const IsolateData&) = default;
|
|
|
|
|
|
|
|
bool serializer_enabled_;
|
|
|
|
#if V8_TARGET_ARCH_X64
|
|
|
|
Address code_range_start_;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
AssemblerBase(IsolateData isolate_data, void* buffer, int buffer_size);
|
2012-11-22 10:28:29 +00:00
|
|
|
virtual ~AssemblerBase();
|
2011-03-22 13:20:04 +00:00
|
|
|
|
2017-03-17 11:18:06 +00:00
|
|
|
IsolateData isolate_data() const { return isolate_data_; }
|
|
|
|
|
|
|
|
bool serializer_enabled() const { return isolate_data_.serializer_enabled_; }
|
|
|
|
void enable_serializer() { isolate_data_.serializer_enabled_ = true; }
|
2012-11-09 13:10:10 +00:00
|
|
|
|
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; }
|
|
|
|
|
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;
|
|
|
|
}
|
2016-09-23 15:29:11 +00:00
|
|
|
// Features are usually enabled by CpuFeatureScope, which also asserts that
|
|
|
|
// the features are supported before they are enabled.
|
2013-03-05 10:48:16 +00:00
|
|
|
bool IsEnabled(CpuFeature f) {
|
|
|
|
return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0;
|
|
|
|
}
|
2016-09-23 15:29:11 +00:00
|
|
|
void EnableCpuFeature(CpuFeature f) {
|
|
|
|
enabled_cpu_features_ |= (static_cast<uint64_t>(1) << f);
|
|
|
|
}
|
2013-03-05 10:48:16 +00:00
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
bool is_constant_pool_available() const {
|
|
|
|
if (FLAG_enable_embedded_constant_pool) {
|
|
|
|
return constant_pool_available_;
|
2014-10-13 14:41:33 +00:00
|
|
|
} else {
|
2015-06-04 14:44:00 +00:00
|
|
|
// Embedded constant pool not supported on this architecture.
|
2014-10-13 14:41:33 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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() { }
|
|
|
|
|
[assembler] Introduce proper AssemblerBase::Print() for improved debuggability.
While working on frame elision, I wanted to disassemble codegen in the
debugger, as the code generation is progressing. I discovered we had a
"Print" member on the x64 assembler, without any implementation. I
pulled it up to AssemblerBase and gave it an implementation that
should work for the other architectures.
Also checked that ia32, x87, arm and arm64 assemblers didn't have
such an implementation - free Print.
Arm64 has a naming conflict with the v8::internal::Disassembler. I
renamed the arm64 type with a more specific name.
Opportunistically fixed a bug in the name converter. This debug-time
printer doesn't provide a Code object, which should be OK with the
name converters, by the looks of other APIs there. All this means is that
when using the Print() API, we just get addresses dumped without any
context (like what this address may be - a stub maybe, etc). This seems
fine for the scenario.
There may be other places that assume a Code object. Since this is
a diagnostics-only scenario, for codegen developers, I feel it is
reasonable to fix such other places as we find them.
Review URL: https://codereview.chromium.org/1431933003
Cr-Commit-Position: refs/heads/master@{#31869}
2015-11-09 05:39:20 +00:00
|
|
|
// Debugging
|
2017-03-17 11:18:06 +00:00
|
|
|
void Print(Isolate* isolate);
|
[assembler] Introduce proper AssemblerBase::Print() for improved debuggability.
While working on frame elision, I wanted to disassemble codegen in the
debugger, as the code generation is progressing. I discovered we had a
"Print" member on the x64 assembler, without any implementation. I
pulled it up to AssemblerBase and gave it an implementation that
should work for the other architectures.
Also checked that ia32, x87, arm and arm64 assemblers didn't have
such an implementation - free Print.
Arm64 has a naming conflict with the v8::internal::Disassembler. I
renamed the arm64 type with a more specific name.
Opportunistically fixed a bug in the name converter. This debug-time
printer doesn't provide a Code object, which should be OK with the
name converters, by the looks of other APIs there. All this means is that
when using the Print() API, we just get addresses dumped without any
context (like what this address may be - a stub maybe, etc). This seems
fine for the scenario.
There may be other places that assume a Code object. Since this is
a diagnostics-only scenario, for codegen developers, I feel it is
reasonable to fix such other places as we find them.
Review URL: https://codereview.chromium.org/1431933003
Cr-Commit-Position: refs/heads/master@{#31869}
2015-11-09 05:39:20 +00:00
|
|
|
|
2012-11-22 10:28:29 +00:00
|
|
|
static const int kMinimalBufferSize = 4*KB;
|
|
|
|
|
2015-09-11 12:59:30 +00:00
|
|
|
static void FlushICache(Isolate* isolate, void* start, size_t size);
|
|
|
|
|
2012-11-22 10:28:29 +00:00
|
|
|
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-04 14:44:00 +00:00
|
|
|
void set_constant_pool_available(bool available) {
|
|
|
|
if (FLAG_enable_embedded_constant_pool) {
|
|
|
|
constant_pool_available_ = available;
|
2014-10-13 14:41:33 +00:00
|
|
|
} else {
|
2015-06-04 14:44:00 +00:00
|
|
|
// Embedded 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:
|
2017-03-17 11:18:06 +00:00
|
|
|
IsolateData isolate_data_;
|
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-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-04 14:44:00 +00:00
|
|
|
bool 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:
|
2015-07-21 11:18:22 +00:00
|
|
|
explicit PredictableCodeSizeScope(AssemblerBase* assembler);
|
2012-11-22 14:59:52 +00:00
|
|
|
PredictableCodeSizeScope(AssemblerBase* assembler, int expected_size);
|
|
|
|
~PredictableCodeSizeScope();
|
2015-07-21 11:18:22 +00:00
|
|
|
void ExpectSize(int expected_size) { expected_size_ = expected_size; }
|
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:
|
2016-09-23 15:29:11 +00:00
|
|
|
enum CheckPolicy {
|
|
|
|
kCheckSupported,
|
|
|
|
kDontCheckSupported,
|
|
|
|
};
|
|
|
|
|
2013-03-05 10:48:16 +00:00
|
|
|
#ifdef DEBUG
|
2016-09-23 15:29:11 +00:00
|
|
|
CpuFeatureScope(AssemblerBase* assembler, CpuFeature f,
|
|
|
|
CheckPolicy check = kCheckSupported);
|
2013-03-05 10:48:16 +00:00
|
|
|
~CpuFeatureScope();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AssemblerBase* assembler_;
|
|
|
|
uint64_t old_enabled_;
|
|
|
|
#else
|
2016-09-23 15:29:11 +00:00
|
|
|
CpuFeatureScope(AssemblerBase* assembler, CpuFeature f,
|
|
|
|
CheckPolicy check = kCheckSupported) {}
|
2013-03-05 10:48:16 +00:00
|
|
|
#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();
|
|
|
|
|
2017-03-15 13:24:54 +00:00
|
|
|
static inline bool SupportsWasmSimd128();
|
2016-07-11 15:32:36 +00:00
|
|
|
|
2016-03-16 16:27:37 +00:00
|
|
|
static inline unsigned icache_line_size() {
|
|
|
|
DCHECK(icache_line_size_ != 0);
|
|
|
|
return icache_line_size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned dcache_line_size() {
|
|
|
|
DCHECK(dcache_line_size_ != 0);
|
|
|
|
return dcache_line_size_;
|
2014-05-16 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintTarget();
|
|
|
|
static void PrintFeatures();
|
2013-09-17 13:02:25 +00:00
|
|
|
|
2015-11-25 19:27:23 +00:00
|
|
|
private:
|
|
|
|
friend class ExternalReference;
|
|
|
|
friend class AssemblerBase;
|
2014-06-30 13:25:46 +00:00
|
|
|
// Flush instruction cache.
|
|
|
|
static void FlushICache(void* start, size_t size);
|
|
|
|
|
2014-05-16 15:18:24 +00:00
|
|
|
// Platform-dependent implementation.
|
|
|
|
static void ProbeImpl(bool cross_compile);
|
|
|
|
|
|
|
|
static unsigned supported_;
|
2016-03-16 16:27:37 +00:00
|
|
|
static unsigned icache_line_size_;
|
|
|
|
static unsigned dcache_line_size_;
|
2014-05-16 15:18:24 +00:00
|
|
|
static bool initialized_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
2013-09-17 13:02:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
enum SaveFPRegsMode { kDontSaveFPRegs, kSaveFPRegs };
|
|
|
|
|
2015-10-02 18:13:41 +00:00
|
|
|
enum ArgvMode { kArgvOnStack, kArgvInRegister };
|
|
|
|
|
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:
|
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
|
|
|
|
2015-07-10 13:14:36 +00:00
|
|
|
// The minimum size of a comment is equal to two bytes for the extra tagged
|
|
|
|
// pc and kPointerSize for the actual pointer to the comment.
|
|
|
|
static const int kMinRelocCommentSize = 2 + 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).
|
2017-04-26 14:54:33 +00:00
|
|
|
CODE_TARGET,
|
2008-09-22 13:57:03 +00:00
|
|
|
EMBEDDED_OBJECT,
|
2017-06-08 07:49:49 +00:00
|
|
|
// Wasm entries are to relocate pointers into the wasm memory embedded in
|
|
|
|
// wasm code. Everything after WASM_MEMORY_REFERENCE (inclusive) is not
|
|
|
|
// GC'ed.
|
2016-03-16 18:13:43 +00:00
|
|
|
WASM_MEMORY_REFERENCE,
|
2016-06-14 21:38:21 +00:00
|
|
|
WASM_GLOBAL_REFERENCE,
|
2016-05-04 20:19:28 +00:00
|
|
|
WASM_MEMORY_SIZE_REFERENCE,
|
2017-01-10 19:07:34 +00:00
|
|
|
WASM_FUNCTION_TABLE_SIZE_REFERENCE,
|
2017-01-31 02:25:57 +00:00
|
|
|
WASM_PROTECTED_INSTRUCTION_LANDING,
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
RUNTIME_ENTRY,
|
|
|
|
COMMENT,
|
2015-07-13 12:32:09 +00:00
|
|
|
|
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
|
|
|
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
DEOPT_SCRIPT_OFFSET,
|
|
|
|
DEOPT_INLINING_ID, // Deoptimization source position.
|
|
|
|
DEOPT_REASON, // Deoptimization reason index.
|
|
|
|
DEOPT_ID, // Deoptimization inlining id.
|
2015-07-10 13:14:36 +00:00
|
|
|
|
|
|
|
// This is not an actual reloc mode, but used to encode a long pc jump that
|
|
|
|
// cannot be encoded as part of another record.
|
|
|
|
PC_JUMP,
|
2015-02-05 14:51:45 +00:00
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
// Pseudo-types
|
2015-07-10 13:14:36 +00:00
|
|
|
NUMBER_OF_MODES,
|
2015-02-05 14:51:45 +00:00
|
|
|
NONE32, // never recorded 32-bit value
|
|
|
|
NONE64, // never recorded 64-bit value
|
2017-08-02 08:23:36 +00:00
|
|
|
CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explicitly by
|
2012-11-08 12:18:11 +00:00
|
|
|
// 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,
|
2017-06-20 13:30:17 +00:00
|
|
|
LAST_CODE_ENUM = CODE_TARGET,
|
2017-06-08 07:49:49 +00:00
|
|
|
LAST_GCED_ENUM = EMBEDDED_OBJECT,
|
2017-07-25 13:05:14 +00:00
|
|
|
FIRST_SHAREABLE_RELOC_MODE = RUNTIME_ENTRY,
|
2008-09-22 13:57:03 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 12:32:09 +00:00
|
|
|
STATIC_ASSERT(NUMBER_OF_MODES <= kBitsPerInt);
|
|
|
|
|
2017-03-17 11:18:06 +00:00
|
|
|
RelocInfo() = default;
|
2011-09-19 18:36:47 +00:00
|
|
|
|
2017-03-17 11:18:06 +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
|
|
|
|
2012-11-08 12:18:11 +00:00
|
|
|
static inline bool IsRealRelocMode(Mode mode) {
|
2016-06-20 05:22:02 +00:00
|
|
|
return mode >= FIRST_REAL_RELOC_MODE && mode <= LAST_REAL_RELOC_MODE;
|
2012-11-08 12:18:11 +00:00
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
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;
|
|
|
|
}
|
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 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;
|
|
|
|
}
|
2016-06-29 13:49:19 +00:00
|
|
|
static inline bool IsDeoptPosition(Mode mode) {
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
return mode == DEOPT_SCRIPT_OFFSET || mode == DEOPT_INLINING_ID;
|
2016-06-29 13:49:19 +00:00
|
|
|
}
|
2015-02-11 17:11:23 +00:00
|
|
|
static inline bool IsDeoptReason(Mode mode) {
|
|
|
|
return mode == DEOPT_REASON;
|
|
|
|
}
|
2016-05-11 14:05:41 +00:00
|
|
|
static inline bool IsDeoptId(Mode mode) {
|
|
|
|
return mode == DEOPT_ID;
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
2016-03-16 18:13:43 +00:00
|
|
|
static inline bool IsWasmMemoryReference(Mode mode) {
|
|
|
|
return mode == WASM_MEMORY_REFERENCE;
|
|
|
|
}
|
2016-05-04 20:19:28 +00:00
|
|
|
static inline bool IsWasmMemorySizeReference(Mode mode) {
|
|
|
|
return mode == WASM_MEMORY_SIZE_REFERENCE;
|
|
|
|
}
|
2016-06-14 21:38:21 +00:00
|
|
|
static inline bool IsWasmGlobalReference(Mode mode) {
|
|
|
|
return mode == WASM_GLOBAL_REFERENCE;
|
|
|
|
}
|
2017-01-10 19:07:34 +00:00
|
|
|
static inline bool IsWasmFunctionTableSizeReference(Mode mode) {
|
|
|
|
return mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE;
|
|
|
|
}
|
|
|
|
static inline bool IsWasmReference(Mode mode) {
|
2017-08-19 07:24:52 +00:00
|
|
|
return mode == WASM_MEMORY_REFERENCE || mode == WASM_GLOBAL_REFERENCE ||
|
|
|
|
mode == WASM_MEMORY_SIZE_REFERENCE ||
|
|
|
|
mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE;
|
2017-01-10 19:07:34 +00:00
|
|
|
}
|
|
|
|
static inline bool IsWasmSizeReference(Mode mode) {
|
|
|
|
return mode == WASM_MEMORY_SIZE_REFERENCE ||
|
|
|
|
mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE;
|
|
|
|
}
|
|
|
|
static inline bool IsWasmPtrReference(Mode mode) {
|
2017-08-19 07:24:52 +00:00
|
|
|
return mode == WASM_MEMORY_REFERENCE || mode == WASM_GLOBAL_REFERENCE;
|
2017-01-10 19:07:34 +00:00
|
|
|
}
|
2017-01-31 02:25:57 +00:00
|
|
|
static inline bool IsWasmProtectedLanding(Mode mode) {
|
|
|
|
return mode == WASM_PROTECTED_INSTRUCTION_LANDING;
|
|
|
|
}
|
2017-01-10 19:07:34 +00:00
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
static inline int ModeMask(Mode mode) { return 1 << mode; }
|
|
|
|
|
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_; }
|
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
|
|
|
|
2015-07-15 09:22:33 +00:00
|
|
|
// Apply a relocation by delta bytes. When the code object is moved, PC
|
|
|
|
// relative addresses have to be updated as well as absolute addresses
|
|
|
|
// inside the code (internal references).
|
|
|
|
// Do not forget to flush the icache afterwards!
|
|
|
|
INLINE(void apply(intptr_t delta));
|
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();
|
|
|
|
|
2017-08-14 17:35:12 +00:00
|
|
|
Address wasm_memory_reference() const;
|
|
|
|
Address wasm_global_reference() const;
|
|
|
|
uint32_t wasm_function_table_size_reference() const;
|
|
|
|
uint32_t wasm_memory_size_reference() const;
|
2016-05-04 20:19:28 +00:00
|
|
|
void update_wasm_memory_reference(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, Address old_base, Address new_base,
|
2017-03-06 12:47:08 +00:00
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
|
|
|
|
void update_wasm_memory_size(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, uint32_t old_size, uint32_t new_size,
|
2016-06-29 07:36:43 +00:00
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
|
2016-06-14 21:38:21 +00:00
|
|
|
void update_wasm_global_reference(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, Address old_base, Address new_base,
|
2016-06-29 07:36:43 +00:00
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
|
2017-01-10 19:07:34 +00:00
|
|
|
void update_wasm_function_table_size_reference(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, uint32_t old_base, uint32_t new_base,
|
2017-01-10 19:07:34 +00:00
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
|
2016-08-17 17:56:22 +00:00
|
|
|
void set_target_address(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, Address target,
|
2016-08-17 17:56:22 +00:00
|
|
|
WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
|
2016-05-04 20:19:28 +00:00
|
|
|
|
2009-01-13 14:38:12 +00:00
|
|
|
// 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());
|
2017-03-07 09:36:07 +00:00
|
|
|
INLINE(HeapObject* target_object());
|
|
|
|
INLINE(Handle<HeapObject> target_object_handle(Assembler* origin));
|
2016-06-20 05:22:02 +00:00
|
|
|
INLINE(void set_target_object(
|
2017-03-07 09:36:07 +00:00
|
|
|
HeapObject* target,
|
2016-06-20 05:22:02 +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));
|
2016-06-20 05:22:02 +00:00
|
|
|
INLINE(void set_target_runtime_entry(
|
2017-03-17 11:18:06 +00:00
|
|
|
Isolate* isolate, Address target,
|
2016-06-20 05:22:02 +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());
|
2016-06-20 05:22:02 +00:00
|
|
|
INLINE(void set_target_cell(
|
|
|
|
Cell* cell, WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER,
|
|
|
|
ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED));
|
2017-03-07 09:36:07 +00:00
|
|
|
INLINE(Handle<Code> code_age_stub_handle(Assembler* origin));
|
2012-11-08 12:18:11 +00:00
|
|
|
INLINE(Code* code_age_stub());
|
2016-06-20 05:22:02 +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
|
|
|
|
2013-11-05 10:14:48 +00:00
|
|
|
// Wipe out a relocation to a fixed value, used for making snapshots
|
|
|
|
// reproducible.
|
2017-03-17 11:18:06 +00:00
|
|
|
INLINE(void WipeOut(Isolate* isolate));
|
2013-11-05 10:14:48 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
template<typename StaticVisitor> inline void Visit(Heap* heap);
|
2016-04-19 07:06:37 +00:00
|
|
|
|
|
|
|
template <typename ObjectVisitor>
|
2013-09-11 10:51:06 +00:00
|
|
|
inline void Visit(Isolate* isolate, ObjectVisitor* v);
|
2010-05-26 08:34:07 +00:00
|
|
|
|
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.
|
2017-03-17 11:18:06 +00:00
|
|
|
static bool RequiresRelocation(Isolate* isolate, const CodeDesc& desc);
|
2013-02-20 13:12:26 +00:00
|
|
|
#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;
|
2015-07-15 09:22:33 +00:00
|
|
|
static const int kApplyMask; // Modes affected by apply. Depends on arch.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
2017-08-14 17:35:12 +00:00
|
|
|
void set_embedded_address(Isolate* isolate, Address address,
|
|
|
|
ICacheFlushMode flush_mode);
|
|
|
|
void set_embedded_size(Isolate* isolate, uint32_t size,
|
|
|
|
ICacheFlushMode flush_mode);
|
|
|
|
|
|
|
|
uint32_t embedded_size() const;
|
|
|
|
Address embedded_address() const;
|
2016-06-20 05:22:02 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// 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-04 14:44:00 +00:00
|
|
|
intptr_t data_;
|
2011-09-19 18:36:47 +00:00
|
|
|
Code* host_;
|
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:
|
2017-06-20 13:30:17 +00:00
|
|
|
RelocInfoWriter() : pos_(NULL), last_pc_(NULL) {}
|
|
|
|
RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc) {}
|
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;
|
|
|
|
}
|
|
|
|
|
2009-06-23 09:50:51 +00:00
|
|
|
// Max size (bytes) of a written RelocInfo. Longest encoding is
|
2015-07-10 13:14:36 +00:00
|
|
|
// ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, data_delta.
|
|
|
|
// On ia32 and arm this is 1 + 4 + 1 + 1 + 4 = 11.
|
|
|
|
// On x64 this is 1 + 4 + 1 + 1 + 8 == 15;
|
2009-06-23 09:50:51 +00:00
|
|
|
// Here we use the maximum of the two.
|
2015-07-10 13:14:36 +00:00
|
|
|
static const int kMaxSize = 15;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
2015-07-10 13:14:36 +00:00
|
|
|
inline uint32_t WriteLongPCJump(uint32_t pc_delta);
|
|
|
|
|
|
|
|
inline void WriteShortTaggedPC(uint32_t pc_delta, int tag);
|
2017-06-20 13:30:17 +00:00
|
|
|
inline void WriteShortData(intptr_t data_delta);
|
2015-07-10 13:14:36 +00:00
|
|
|
|
|
|
|
inline void WriteMode(RelocInfo::Mode rmode);
|
|
|
|
inline void WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode);
|
|
|
|
inline void WriteIntData(int data_delta);
|
|
|
|
inline void WriteData(intptr_t data_delta);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
byte* pos_;
|
|
|
|
byte* last_pc_;
|
2015-02-12 12:15:14 +00:00
|
|
|
RelocInfo::Mode last_mode_;
|
|
|
|
|
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();
|
2015-07-10 13:14:36 +00:00
|
|
|
RelocInfo::Mode GetMode();
|
|
|
|
|
|
|
|
void AdvanceReadLongPCJump();
|
|
|
|
|
|
|
|
void ReadShortTaggedPC();
|
2017-06-20 13:30:17 +00:00
|
|
|
void ReadShortData();
|
2015-07-10 13:14:36 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void AdvanceReadPC();
|
2015-07-10 08:49:14 +00:00
|
|
|
void AdvanceReadInt();
|
2008-07-03 15:10:15 +00:00
|
|
|
void AdvanceReadData();
|
|
|
|
|
|
|
|
// 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_;
|
2008-08-28 09:55:41 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(RelocIterator);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// External function
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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.
|
2016-01-22 18:34:32 +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
|
|
|
|
2016-01-22 18:34:32 +00:00
|
|
|
// Builtin call returning object pair.
|
|
|
|
// ObjectPair f(v8::internal::Arguments).
|
|
|
|
BUILTIN_CALL_PAIR,
|
|
|
|
|
2016-01-15 14:34:38 +00:00
|
|
|
// Builtin call that returns .
|
|
|
|
// ObjectTriple f(v8::internal::Arguments).
|
|
|
|
BUILTIN_CALL_TRIPLE,
|
|
|
|
|
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();
|
|
|
|
|
2017-05-02 09:11:46 +00:00
|
|
|
// These functions must use the isolate in a thread-safe way.
|
2015-11-23 08:09:34 +00:00
|
|
|
typedef void* ExternalReferenceRedirector(Isolate* isolate, void* original,
|
|
|
|
Type type);
|
2011-02-04 13:43:38 +00:00
|
|
|
|
2013-07-29 13:56:51 +00:00
|
|
|
ExternalReference() : address_(NULL) {}
|
|
|
|
|
2016-07-18 08:47:04 +00:00
|
|
|
ExternalReference(Address address, 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(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
|
|
|
|
|
|
|
explicit ExternalReference(StatsCounter* counter);
|
|
|
|
|
2017-06-23 12:21:39 +00:00
|
|
|
ExternalReference(IsolateAddressId 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.
|
|
|
|
|
2016-02-05 14:32:38 +00:00
|
|
|
static ExternalReference interpreter_dispatch_table_address(Isolate* isolate);
|
2016-04-11 11:57:31 +00:00
|
|
|
static ExternalReference interpreter_dispatch_counters(Isolate* isolate);
|
2016-02-05 14:32:38 +00:00
|
|
|
|
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-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
|
|
|
|
2016-03-04 09:50:48 +00:00
|
|
|
static ExternalReference wasm_f32_trunc(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f32_floor(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f32_ceil(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f32_nearest_int(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f64_trunc(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f64_floor(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f64_ceil(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_f64_nearest_int(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_int64_to_float32(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_uint64_to_float32(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_int64_to_float64(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_uint64_to_float64(Isolate* isolate);
|
2016-03-14 10:13:49 +00:00
|
|
|
static ExternalReference wasm_float32_to_int64(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_float32_to_uint64(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_float64_to_int64(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_float64_to_uint64(Isolate* isolate);
|
2016-03-15 06:51:53 +00:00
|
|
|
static ExternalReference wasm_int64_div(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_int64_mod(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_uint64_div(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_uint64_mod(Isolate* isolate);
|
2016-04-21 07:45:36 +00:00
|
|
|
static ExternalReference wasm_word32_ctz(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_word64_ctz(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_word32_popcnt(Isolate* isolate);
|
|
|
|
static ExternalReference wasm_word64_popcnt(Isolate* isolate);
|
2016-07-20 14:24:47 +00:00
|
|
|
static ExternalReference wasm_float64_pow(Isolate* isolate);
|
2016-02-02 10:57:58 +00:00
|
|
|
|
2016-03-03 01:22:01 +00:00
|
|
|
static ExternalReference f64_acos_wrapper_function(Isolate* isolate);
|
|
|
|
static ExternalReference f64_asin_wrapper_function(Isolate* isolate);
|
|
|
|
static ExternalReference f64_mod_wrapper_function(Isolate* isolate);
|
|
|
|
|
[wasm] Introduce the TrapIf and TrapUnless operators to generate trap code.
Some instructions in WebAssembly trap for some inputs, which means that the
execution is terminated and (at least at the moment) a JavaScript exception is
thrown. Examples for traps are out-of-bounds memory accesses, or integer
divisions by zero.
Without the TrapIf and TrapUnless operators trap check in WebAssembly introduces 5
TurboFan nodes (branch, if_true, if_false, trap-reason constant, trap-position
constant), in addition to the trap condition itself. Additionally, each
WebAssembly function has four TurboFan nodes (merge, effect_phi, 2 phis) whose
number of inputs is linear to the number of trap checks in the function.
Especially for functions with high numbers of trap checks we observe a
significant slowdown in compilation time, down to 0.22 MiB/s in the sqlite
benchmark instead of the average of 3 MiB/s in other benchmarks. By introducing
a TrapIf common operator only a single node is necessary per trap check, in
addition to the trap condition. Also the nodes which are shared between trap
checks (merge, effect_phi, 2 phis) would disappear. First measurements suggest a
speedup of 30-50% on average.
This CL only implements TrapIf and TrapUnless on x64. The implementation is also
hidden behind the --wasm-trap-if flag.
Please take a special look at how the source position is transfered from the
instruction selector to the code generator, and at the context that is used for
the runtime call.
R=titzer@chromium.org
Review-Url: https://codereview.chromium.org/2562393002
Cr-Commit-Position: refs/heads/master@{#41720}
2016-12-15 13:31:29 +00:00
|
|
|
// Trap callback function for cctest/wasm/wasm-run-utils.h
|
|
|
|
static ExternalReference wasm_call_trap_callback_for_testing(
|
|
|
|
Isolate* isolate);
|
|
|
|
|
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);
|
|
|
|
|
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()
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE 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
|
|
|
|
2017-03-31 09:20:13 +00:00
|
|
|
// Direct access to FLAG_harmony_regexp_dotall.
|
|
|
|
static ExternalReference address_of_regexp_dotall_flag(Isolate* isolate);
|
|
|
|
|
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
|
|
|
|
2011-09-19 18:36:47 +00:00
|
|
|
// Write barrier.
|
|
|
|
static ExternalReference store_buffer_top(Isolate* isolate);
|
2017-08-03 11:17:17 +00:00
|
|
|
static ExternalReference heap_is_marking_flag_address(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);
|
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
|
|
|
|
2016-07-21 11:01:44 +00:00
|
|
|
// Static variables containing simd constants.
|
|
|
|
static ExternalReference address_of_float_abs_constant();
|
|
|
|
static ExternalReference address_of_float_neg_constant();
|
|
|
|
static ExternalReference address_of_double_abs_constant();
|
|
|
|
static ExternalReference address_of_double_neg_constant();
|
|
|
|
|
2016-06-10 05:51:58 +00:00
|
|
|
// IEEE 754 functions.
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
static ExternalReference ieee754_acos_function(Isolate* isolate);
|
|
|
|
static ExternalReference ieee754_acosh_function(Isolate* isolate);
|
|
|
|
static ExternalReference ieee754_asin_function(Isolate* isolate);
|
|
|
|
static ExternalReference ieee754_asinh_function(Isolate* isolate);
|
2016-06-13 07:06:49 +00:00
|
|
|
static ExternalReference ieee754_atan_function(Isolate* isolate);
|
2016-06-17 15:21:48 +00:00
|
|
|
static ExternalReference ieee754_atanh_function(Isolate* isolate);
|
[builtins] Unify most of the remaining Math builtins.
Import fdlibm versions of acos, acosh, asin and asinh, which are more
precise and produce the same result across platforms (we were using
libm versions for asin and acos so far, where both speed and precision
depended on the operating system so far). Introduce appropriate TurboFan
operators for these functions and use them both for inlining and for the
generic builtin.
Also migrate the Math.imul and Math.fround builtins to TurboFan builtins
to ensure that their behavior is always exactly the same as the inlined
TurboFan version (i.e. C++ truncation semantics for double to float
don't necessarily meet the JavaScript semantics).
For completeness, also migrate Math.sign, which can even get some nice
love in TurboFan.
Drive-by-fix: Some alpha-sorting on the Math related functions, and
cleanup the list of Math intrinsics that we have to export via the
native context currently.
BUG=v8:3266,v8:3496,v8:3509,v8:3952,v8:5169,v8:5170,v8:5171,v8:5172
TBR=rossberg@chromium.org
R=franzih@chromium.org
Review-Url: https://codereview.chromium.org/2116753002
Cr-Commit-Position: refs/heads/master@{#37476}
2016-07-01 11:11:33 +00:00
|
|
|
static ExternalReference ieee754_atan2_function(Isolate* isolate);
|
2016-06-17 15:21:48 +00:00
|
|
|
static ExternalReference ieee754_cbrt_function(Isolate* isolate);
|
|
|
|
static ExternalReference ieee754_cos_function(Isolate* isolate);
|
2016-06-30 08:41:05 +00:00
|
|
|
static ExternalReference ieee754_cosh_function(Isolate* isolate);
|
2016-06-17 05:19:35 +00:00
|
|
|
static ExternalReference ieee754_exp_function(Isolate* isolate);
|
2016-06-17 15:21:48 +00:00
|
|
|
static ExternalReference ieee754_expm1_function(Isolate* isolate);
|
2016-06-10 05:51:58 +00:00
|
|
|
static ExternalReference ieee754_log_function(Isolate* isolate);
|
2016-06-13 05:46:38 +00:00
|
|
|
static ExternalReference ieee754_log1p_function(Isolate* isolate);
|
2016-06-16 11:22:32 +00:00
|
|
|
static ExternalReference ieee754_log10_function(Isolate* isolate);
|
2016-06-17 15:21:48 +00:00
|
|
|
static ExternalReference ieee754_log2_function(Isolate* isolate);
|
|
|
|
static ExternalReference ieee754_sin_function(Isolate* isolate);
|
2016-06-30 08:41:05 +00:00
|
|
|
static ExternalReference ieee754_sinh_function(Isolate* isolate);
|
2016-06-20 05:51:37 +00:00
|
|
|
static ExternalReference ieee754_tan_function(Isolate* isolate);
|
2016-06-30 08:41:05 +00:00
|
|
|
static ExternalReference ieee754_tanh_function(Isolate* isolate);
|
2011-03-02 14:40:38 +00:00
|
|
|
|
2016-12-16 13:24:07 +00:00
|
|
|
static ExternalReference libc_memchr_function(Isolate* isolate);
|
[builtins] Copy array contents using JS in ConstructByArrayLike.
The last CL https://chromium-review.googlesource.com/c/456707/ caused
some pretty heavy performance regressions. After experimenting, it
seems the easiest and most straight-forward way to copy the elements
into the new typed array is to do it in JS.
Adds a fast path for typed arrays, where the source typed array has
the same elements kind, in which case we can just copy the backing
store using memcpy.
This CL also removes regression test 319120 which is from a pwn2own
vulnerability. The old code path enforced a maximum byte_length
that was too low, which this change removes. The length property of
the typed array must be a Smi, but the byte_length, which can be up
to 8x larger than length for a Float64Array, can be a heap number.
We can also re-use some of the logic from ConstructByLength when
deciding whether to allocate the buffer on- or off-heap, so that
is factored out into InitializeBasedOnLength. We can also re-use
the DoInitialize helper instead of calling into the runtime,
meaning we can remove InitializeFromArrayLike.
BUG=v8:5977,chromium:705503,chromium:705394
Change-Id: I63372652091d4bdf3a9491acef9b4e3ac793a755
Reviewed-on: https://chromium-review.googlesource.com/459621
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44301}
2017-03-30 13:16:55 +00:00
|
|
|
static ExternalReference libc_memcpy_function(Isolate* isolate);
|
2017-05-17 14:39:34 +00:00
|
|
|
static ExternalReference libc_memmove_function(Isolate* isolate);
|
2017-03-02 13:35:39 +00:00
|
|
|
static ExternalReference libc_memset_function(Isolate* isolate);
|
2016-12-16 13:24:07 +00:00
|
|
|
|
2017-04-13 14:41:22 +00:00
|
|
|
static ExternalReference try_internalize_string_function(Isolate* isolate);
|
|
|
|
|
2017-08-03 14:27:11 +00:00
|
|
|
static ExternalReference check_object_type(Isolate* isolate);
|
|
|
|
|
2017-05-05 15:59:08 +00:00
|
|
|
#ifdef V8_INTL_SUPPORT
|
|
|
|
static ExternalReference intl_convert_one_byte_to_lower(Isolate* isolate);
|
|
|
|
static ExternalReference intl_to_latin1_lower_table(Isolate* isolate);
|
|
|
|
#endif // V8_INTL_SUPPORT
|
|
|
|
|
2017-04-19 10:47:03 +00:00
|
|
|
template <typename SubjectChar, typename PatternChar>
|
|
|
|
static ExternalReference search_string_raw(Isolate* isolate);
|
|
|
|
|
2017-07-10 11:30:04 +00:00
|
|
|
static ExternalReference orderedhashmap_gethash_raw(Isolate* isolate);
|
2017-06-01 15:33:05 +00:00
|
|
|
|
2017-06-02 10:28:57 +00:00
|
|
|
template <typename CollectionType, int entrysize>
|
|
|
|
static ExternalReference orderedhashtable_has_raw(Isolate* isolate);
|
|
|
|
|
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);
|
2017-01-12 14:18:45 +00:00
|
|
|
static ExternalReference debug_hook_on_function_call_address(
|
|
|
|
Isolate* isolate);
|
2014-05-22 07:57:33 +00:00
|
|
|
|
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);
|
|
|
|
|
[inspector] change target promise for kDebugWillHandle & kDebugDidHandle
- kDebugPromiseCreated(task, parent_task)
This event occurs when promise is created (PromiseHookType::Init). V8Debugger uses this event to maintain task -> parent task map.
- kDebugEnqueueAsyncFunction(task)
This event occurs when first internal promise for async function is created. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseResolve(task),
This event occurs when Promise fulfills with resolved status. V8Debugger collects stack trace at this point.
- kDebugEnqueuePromiseReject(task),
This event occurs when Promise fulfills with rejected status. V8Debugger collects stack trace at this point.
- kDebugPromiseCollected,
This event occurs when Promise is collected and no other chained callbacks can be added. V8Debugger removes information about async task for this promise.
- kDebugWillHandle,
This event occurs when chained promise function (either resolve or reject handler) is called. V8Debugger installs parent promise's stack (based on task -> parent_task map) as current if available or current promise's scheduled stack otherwise.
- kDebugDidHandle,
This event occurs after chained promise function has finished. V8Debugger restores asynchronous call chain to previous one.
With this change all instrumentation calls are related to current promise (before WillHandle and DidHandle were related to next async task).
Before V8Debugger supported only the following:
- asyncTaskScheduled(task1)
- asyncTaskStarted(task1)
- asyncTaskFinished(task1)
Now V8Debugger supports the following:
- asyncTaskScheduled(parent_task)
..
- asyncTaskCreated(task, parent_task),
- asyncTaskStarted(task), uses parent_task scheduled stack
- asyncTaskScheduled(task)
- asyncTaskFinished(task)
Additionally: WillHandle and DidHandle were migrated to PromiseHook API.
More details: https://docs.google.com/document/d/1u19N45f1gSF7M39mGsycJEK3IPyJgIXCBnWyiPeuJFE
BUG=v8:5738
R=dgozman@chromium.org,gsathya@chromium.org,yangguo@chromium.org
Review-Url: https://codereview.chromium.org/2650803003
Cr-Commit-Position: refs/heads/master@{#42644}
2017-01-25 07:05:43 +00:00
|
|
|
static ExternalReference promise_hook_or_debug_is_active_address(
|
|
|
|
Isolate* isolate);
|
2016-12-09 06:56:43 +00:00
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE static ExternalReference runtime_function_table_address(
|
|
|
|
Isolate* isolate);
|
2015-10-02 18:13:41 +00:00
|
|
|
|
2013-07-29 13:56:51 +00:00
|
|
|
Address address() const { return reinterpret_cast<Address>(address_); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2016-06-14 11:07:40 +00:00
|
|
|
// Used to read out the last step action of the debugger.
|
|
|
|
static ExternalReference debug_last_step_action_address(Isolate* isolate);
|
2009-04-20 16:36:13 +00:00
|
|
|
|
2016-06-03 15:30:42 +00:00
|
|
|
// Used to check for suspended generator, used for stepping across await call.
|
|
|
|
static ExternalReference debug_suspended_generator_address(Isolate* isolate);
|
|
|
|
|
2017-01-27 07:31:03 +00:00
|
|
|
// Used to store the frame pointer to drop to when restarting a frame.
|
|
|
|
static ExternalReference debug_restart_fp_address(Isolate* isolate);
|
|
|
|
|
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,
|
2017-06-23 12:21:39 +00:00
|
|
|
ExternalReferenceRedirector* redirector);
|
2009-06-09 09:26:53 +00:00
|
|
|
|
2013-07-18 08:12:01 +00:00
|
|
|
static ExternalReference stress_deopt_count(Isolate* isolate);
|
|
|
|
|
2015-07-22 10:25:51 +00:00
|
|
|
static ExternalReference fixed_typed_array_base_data_offset();
|
|
|
|
|
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);
|
2015-11-23 08:09:34 +00:00
|
|
|
void* answer =
|
|
|
|
(redirector == NULL) ? address : (*redirector)(isolate, 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
|
|
|
};
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE bool operator==(ExternalReference, ExternalReference);
|
2014-10-07 13:30:28 +00:00
|
|
|
bool operator!=(ExternalReference, ExternalReference);
|
|
|
|
|
|
|
|
size_t hash_value(ExternalReference);
|
|
|
|
|
2016-10-17 10:01:42 +00:00
|
|
|
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ExternalReference);
|
2014-10-07 13:30:28 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Utility functions
|
|
|
|
|
2010-12-08 14:32:40 +00:00
|
|
|
// Computes pow(x, y) with the special cases in the spec for Math.pow.
|
2015-11-25 16:37:11 +00:00
|
|
|
double power_helper(Isolate* isolate, 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);
|
|
|
|
|
2015-11-26 14:12:04 +00:00
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Constant pool support
|
|
|
|
|
|
|
|
class ConstantPoolEntry {
|
|
|
|
public:
|
|
|
|
ConstantPoolEntry() {}
|
|
|
|
ConstantPoolEntry(int position, intptr_t value, bool sharing_ok)
|
|
|
|
: position_(position),
|
|
|
|
merged_index_(sharing_ok ? SHARING_ALLOWED : SHARING_PROHIBITED),
|
|
|
|
value_(value) {}
|
2017-07-05 13:48:12 +00:00
|
|
|
ConstantPoolEntry(int position, Double value)
|
|
|
|
: position_(position),
|
|
|
|
merged_index_(SHARING_ALLOWED),
|
|
|
|
value64_(value.AsUint64()) {}
|
2015-06-04 14:44:00 +00:00
|
|
|
|
|
|
|
int position() const { return position_; }
|
|
|
|
bool sharing_ok() const { return merged_index_ != SHARING_PROHIBITED; }
|
|
|
|
bool is_merged() const { return merged_index_ >= 0; }
|
|
|
|
int merged_index(void) const {
|
|
|
|
DCHECK(is_merged());
|
|
|
|
return merged_index_;
|
|
|
|
}
|
|
|
|
void set_merged_index(int index) {
|
2017-05-23 18:30:32 +00:00
|
|
|
DCHECK(sharing_ok());
|
2015-06-04 14:44:00 +00:00
|
|
|
merged_index_ = index;
|
|
|
|
DCHECK(is_merged());
|
|
|
|
}
|
|
|
|
int offset(void) const {
|
|
|
|
DCHECK(merged_index_ >= 0);
|
|
|
|
return merged_index_;
|
|
|
|
}
|
|
|
|
void set_offset(int offset) {
|
|
|
|
DCHECK(offset >= 0);
|
|
|
|
merged_index_ = offset;
|
|
|
|
}
|
|
|
|
intptr_t value() const { return value_; }
|
2017-07-05 13:48:12 +00:00
|
|
|
uint64_t value64() const { return value64_; }
|
2015-06-04 14:44:00 +00:00
|
|
|
|
|
|
|
enum Type { INTPTR, DOUBLE, NUMBER_OF_TYPES };
|
|
|
|
|
|
|
|
static int size(Type type) {
|
|
|
|
return (type == INTPTR) ? kPointerSize : kDoubleSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Access { REGULAR, OVERFLOWED };
|
|
|
|
|
|
|
|
private:
|
|
|
|
int position_;
|
|
|
|
int merged_index_;
|
|
|
|
union {
|
|
|
|
intptr_t value_;
|
2017-07-05 13:48:12 +00:00
|
|
|
uint64_t value64_;
|
2015-06-04 14:44:00 +00:00
|
|
|
};
|
|
|
|
enum { SHARING_PROHIBITED = -2, SHARING_ALLOWED = -1 };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Embedded constant pool support
|
|
|
|
|
|
|
|
class ConstantPoolBuilder BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
ConstantPoolBuilder(int ptr_reach_bits, int double_reach_bits);
|
|
|
|
|
|
|
|
// Add pointer-sized constant to the embedded constant pool
|
|
|
|
ConstantPoolEntry::Access AddEntry(int position, intptr_t value,
|
|
|
|
bool sharing_ok) {
|
|
|
|
ConstantPoolEntry entry(position, value, sharing_ok);
|
|
|
|
return AddEntry(entry, ConstantPoolEntry::INTPTR);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add double constant to the embedded constant pool
|
2017-07-07 14:04:32 +00:00
|
|
|
ConstantPoolEntry::Access AddEntry(int position, Double value) {
|
|
|
|
ConstantPoolEntry entry(position, value);
|
2015-06-04 14:44:00 +00:00
|
|
|
return AddEntry(entry, ConstantPoolEntry::DOUBLE);
|
|
|
|
}
|
|
|
|
|
2017-07-07 14:04:32 +00:00
|
|
|
// Add double constant to the embedded constant pool
|
|
|
|
ConstantPoolEntry::Access AddEntry(int position, double value) {
|
|
|
|
return AddEntry(position, Double(value));
|
|
|
|
}
|
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
// Previews the access type required for the next new entry to be added.
|
|
|
|
ConstantPoolEntry::Access NextAccess(ConstantPoolEntry::Type type) const;
|
|
|
|
|
|
|
|
bool IsEmpty() {
|
|
|
|
return info_[ConstantPoolEntry::INTPTR].entries.empty() &&
|
|
|
|
info_[ConstantPoolEntry::INTPTR].shared_entries.empty() &&
|
|
|
|
info_[ConstantPoolEntry::DOUBLE].entries.empty() &&
|
|
|
|
info_[ConstantPoolEntry::DOUBLE].shared_entries.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit the constant pool. Invoke only after all entries have been
|
|
|
|
// added and all instructions have been emitted.
|
|
|
|
// Returns position of the emitted pool (zero implies no constant pool).
|
|
|
|
int Emit(Assembler* assm);
|
|
|
|
|
|
|
|
// Returns the label associated with the start of the constant pool.
|
|
|
|
// Linking to this label in the function prologue may provide an
|
|
|
|
// efficient means of constant pool pointer register initialization
|
|
|
|
// on some architectures.
|
|
|
|
inline Label* EmittedPosition() { return &emitted_label_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
ConstantPoolEntry::Access AddEntry(ConstantPoolEntry& entry,
|
|
|
|
ConstantPoolEntry::Type type);
|
|
|
|
void EmitSharedEntries(Assembler* assm, ConstantPoolEntry::Type type);
|
|
|
|
void EmitGroup(Assembler* assm, ConstantPoolEntry::Access access,
|
|
|
|
ConstantPoolEntry::Type type);
|
|
|
|
|
|
|
|
struct PerTypeEntryInfo {
|
|
|
|
PerTypeEntryInfo() : regular_count(0), overflow_start(-1) {}
|
|
|
|
bool overflow() const {
|
|
|
|
return (overflow_start >= 0 &&
|
|
|
|
overflow_start < static_cast<int>(entries.size()));
|
|
|
|
}
|
|
|
|
int regular_reach_bits;
|
|
|
|
int regular_count;
|
|
|
|
int overflow_start;
|
|
|
|
std::vector<ConstantPoolEntry> entries;
|
|
|
|
std::vector<ConstantPoolEntry> shared_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
Label emitted_label_; // Records pc_offset of emitted pool
|
|
|
|
PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
|
|
|
|
};
|
|
|
|
|
2017-06-28 18:46:29 +00:00
|
|
|
class HeapObjectRequest {
|
|
|
|
public:
|
|
|
|
explicit HeapObjectRequest(double heap_number, int offset = -1);
|
|
|
|
explicit HeapObjectRequest(CodeStub* code_stub, int offset = -1);
|
|
|
|
|
|
|
|
enum Kind { kHeapNumber, kCodeStub };
|
|
|
|
Kind kind() const { return kind_; }
|
|
|
|
|
|
|
|
double heap_number() const {
|
|
|
|
DCHECK_EQ(kind(), kHeapNumber);
|
|
|
|
return value_.heap_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeStub* code_stub() const {
|
|
|
|
DCHECK_EQ(kind(), kCodeStub);
|
|
|
|
return value_.code_stub;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The code buffer offset at the time of the request.
|
|
|
|
int offset() const {
|
|
|
|
DCHECK_GE(offset_, 0);
|
|
|
|
return offset_;
|
|
|
|
}
|
|
|
|
void set_offset(int offset) {
|
|
|
|
DCHECK_LT(offset_, 0);
|
|
|
|
offset_ = offset;
|
|
|
|
DCHECK_GE(offset_, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Kind kind_;
|
|
|
|
|
|
|
|
union {
|
|
|
|
double heap_number;
|
|
|
|
CodeStub* code_stub;
|
|
|
|
} value_;
|
|
|
|
|
|
|
|
int offset_;
|
|
|
|
};
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif // V8_ASSEMBLER_H_
|