Commit 973fc5b9 authored by danno's avatar danno Committed by Commit bot

Separate CodeAssembler and CodeStubAssembler

This separation is needed to make two goals possible simultaneously:
* is should be possible to offer V8 components a simple, clean
  interface to TurboFan's low-level code generation that doesn't
  expose details about the TF.
* it should be possible to easily create new CodeAssembler "macros"
  that don't require a review from an OWNER of the compiler directory.

Review URL: https://codereview.chromium.org/1875583003

Cr-Commit-Position: refs/heads/master@{#35576}
parent 19b58454
...@@ -755,6 +755,8 @@ source_set("v8_base") { ...@@ -755,6 +755,8 @@ source_set("v8_base") {
"src/checks.h", "src/checks.h",
"src/code-factory.cc", "src/code-factory.cc",
"src/code-factory.h", "src/code-factory.h",
"src/code-stub-assembler.cc",
"src/code-stub-assembler.h",
"src/code-stubs-hydrogen.cc", "src/code-stubs-hydrogen.cc",
"src/code-stubs.cc", "src/code-stubs.cc",
"src/code-stubs.h", "src/code-stubs.h",
...@@ -792,11 +794,11 @@ source_set("v8_base") { ...@@ -792,11 +794,11 @@ source_set("v8_base") {
"src/compiler/change-lowering.h", "src/compiler/change-lowering.h",
"src/compiler/coalesced-live-ranges.cc", "src/compiler/coalesced-live-ranges.cc",
"src/compiler/coalesced-live-ranges.h", "src/compiler/coalesced-live-ranges.h",
"src/compiler/code-assembler.cc",
"src/compiler/code-assembler.h",
"src/compiler/code-generator-impl.h", "src/compiler/code-generator-impl.h",
"src/compiler/code-generator.cc", "src/compiler/code-generator.cc",
"src/compiler/code-generator.h", "src/compiler/code-generator.h",
"src/compiler/code-stub-assembler.cc",
"src/compiler/code-stub-assembler.h",
"src/compiler/common-node-cache.cc", "src/compiler/common-node-cache.cc",
"src/compiler/common-node-cache.h", "src/compiler/common-node-cache.h",
"src/compiler/common-operator-reducer.cc", "src/compiler/common-operator-reducer.cc",
......
...@@ -3,7 +3,7 @@ include_rules = [ ...@@ -3,7 +3,7 @@ include_rules = [
"+src", "+src",
"-src/compiler", "-src/compiler",
"+src/compiler/pipeline.h", "+src/compiler/pipeline.h",
"+src/compiler/code-stub-assembler.h", "+src/compiler/code-assembler.h",
"+src/compiler/wasm-compiler.h", "+src/compiler/wasm-compiler.h",
"-src/heap", "-src/heap",
"+src/heap/heap.h", "+src/heap/heap.h",
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#include "src/builtins.h" #include "src/builtins.h"
#include "src/api.h"
#include "src/api-arguments.h" #include "src/api-arguments.h"
#include "src/api-natives.h" #include "src/api-natives.h"
#include "src/api.h"
#include "src/base/once.h" #include "src/base/once.h"
#include "src/bootstrapper.h" #include "src/bootstrapper.h"
#include "src/code-factory.h" #include "src/code-factory.h"
#include "src/compiler/code-stub-assembler.h" #include "src/code-stub-assembler.h"
#include "src/dateparser-inl.h" #include "src/dateparser-inl.h"
#include "src/elements.h" #include "src/elements.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
...@@ -352,11 +352,10 @@ BUILTIN(Illegal) { ...@@ -352,11 +352,10 @@ BUILTIN(Illegal) {
BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); } BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); }
void Builtins::Generate_ObjectHasOwnProperty( void Builtins::Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler) {
compiler::CodeStubAssembler* assembler) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* object = assembler->Parameter(0); Node* object = assembler->Parameter(0);
Node* key = assembler->Parameter(1); Node* key = assembler->Parameter(1);
...@@ -2134,12 +2133,11 @@ BUILTIN(MathAtan) { ...@@ -2134,12 +2133,11 @@ BUILTIN(MathAtan) {
namespace { namespace {
void Generate_MathRoundingOperation( void Generate_MathRoundingOperation(
compiler::CodeStubAssembler* assembler, CodeStubAssembler* assembler,
compiler::Node* (compiler::CodeStubAssembler::*float64op)( compiler::Node* (CodeStubAssembler::*float64op)(compiler::Node*)) {
compiler::Node*)) { typedef CodeStubAssembler::Label Label;
typedef compiler::CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(4); Node* context = assembler->Parameter(4);
...@@ -2196,16 +2194,15 @@ void Generate_MathRoundingOperation( ...@@ -2196,16 +2194,15 @@ void Generate_MathRoundingOperation(
} // namespace } // namespace
// ES6 section 20.2.2.10 Math.ceil ( x ) // ES6 section 20.2.2.10 Math.ceil ( x )
void Builtins::Generate_MathCeil(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathCeil(CodeStubAssembler* assembler) {
Generate_MathRoundingOperation(assembler, Generate_MathRoundingOperation(assembler, &CodeStubAssembler::Float64Ceil);
&compiler::CodeStubAssembler::Float64Ceil);
} }
// ES6 section 20.2.2.11 Math.clz32 ( x ) // ES6 section 20.2.2.11 Math.clz32 ( x )
void Builtins::Generate_MathClz32(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathClz32(CodeStubAssembler* assembler) {
typedef compiler::CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* context = assembler->Parameter(4); Node* context = assembler->Parameter(4);
...@@ -2270,9 +2267,8 @@ void Builtins::Generate_MathClz32(compiler::CodeStubAssembler* assembler) { ...@@ -2270,9 +2267,8 @@ void Builtins::Generate_MathClz32(compiler::CodeStubAssembler* assembler) {
} }
// ES6 section 20.2.2.16 Math.floor ( x ) // ES6 section 20.2.2.16 Math.floor ( x )
void Builtins::Generate_MathFloor(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathFloor(CodeStubAssembler* assembler) {
Generate_MathRoundingOperation(assembler, Generate_MathRoundingOperation(assembler, &CodeStubAssembler::Float64Floor);
&compiler::CodeStubAssembler::Float64Floor);
} }
// ES6 section 20.2.2.17 Math.fround ( x ) // ES6 section 20.2.2.17 Math.fround ( x )
...@@ -2298,13 +2294,12 @@ BUILTIN(MathImul) { ...@@ -2298,13 +2294,12 @@ BUILTIN(MathImul) {
} }
// ES6 section 20.2.2.28 Math.round ( x ) // ES6 section 20.2.2.28 Math.round ( x )
void Builtins::Generate_MathRound(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathRound(CodeStubAssembler* assembler) {
Generate_MathRoundingOperation(assembler, Generate_MathRoundingOperation(assembler, &CodeStubAssembler::Float64Round);
&compiler::CodeStubAssembler::Float64Round);
} }
// ES6 section 20.2.2.32 Math.sqrt ( x ) // ES6 section 20.2.2.32 Math.sqrt ( x )
void Builtins::Generate_MathSqrt(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathSqrt(CodeStubAssembler* assembler) {
using compiler::Node; using compiler::Node;
Node* x = assembler->Parameter(1); Node* x = assembler->Parameter(1);
...@@ -2316,9 +2311,8 @@ void Builtins::Generate_MathSqrt(compiler::CodeStubAssembler* assembler) { ...@@ -2316,9 +2311,8 @@ void Builtins::Generate_MathSqrt(compiler::CodeStubAssembler* assembler) {
} }
// ES6 section 20.2.2.35 Math.trunc ( x ) // ES6 section 20.2.2.35 Math.trunc ( x )
void Builtins::Generate_MathTrunc(compiler::CodeStubAssembler* assembler) { void Builtins::Generate_MathTrunc(CodeStubAssembler* assembler) {
Generate_MathRoundingOperation(assembler, Generate_MathRoundingOperation(assembler, &CodeStubAssembler::Float64Trunc);
&compiler::CodeStubAssembler::Float64Trunc);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -2327,9 +2321,9 @@ void Builtins::Generate_MathTrunc(compiler::CodeStubAssembler* assembler) { ...@@ -2327,9 +2321,9 @@ void Builtins::Generate_MathTrunc(compiler::CodeStubAssembler* assembler) {
namespace { namespace {
void Generate_GeneratorPrototypeResume( void Generate_GeneratorPrototypeResume(
compiler::CodeStubAssembler* assembler, CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode,
JSGeneratorObject::ResumeMode resume_mode, char const* const method_name) { char const* const method_name) {
typedef compiler::CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
Node* receiver = assembler->Parameter(0); Node* receiver = assembler->Parameter(0);
...@@ -2406,22 +2400,19 @@ void Generate_GeneratorPrototypeResume( ...@@ -2406,22 +2400,19 @@ void Generate_GeneratorPrototypeResume(
} // namespace } // namespace
// ES6 section 25.3.1.2 Generator.prototype.next ( value ) // ES6 section 25.3.1.2 Generator.prototype.next ( value )
void Builtins::Generate_GeneratorPrototypeNext( void Builtins::Generate_GeneratorPrototypeNext(CodeStubAssembler* assembler) {
compiler::CodeStubAssembler* assembler) {
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kNext, Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kNext,
"[Generator].prototype.next"); "[Generator].prototype.next");
} }
// ES6 section 25.3.1.3 Generator.prototype.return ( value ) // ES6 section 25.3.1.3 Generator.prototype.return ( value )
void Builtins::Generate_GeneratorPrototypeReturn( void Builtins::Generate_GeneratorPrototypeReturn(CodeStubAssembler* assembler) {
compiler::CodeStubAssembler* assembler) {
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kReturn, Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kReturn,
"[Generator].prototype.return"); "[Generator].prototype.return");
} }
// ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) // ES6 section 25.3.1.4 Generator.prototype.throw ( exception )
void Builtins::Generate_GeneratorPrototypeThrow( void Builtins::Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler) {
compiler::CodeStubAssembler* assembler) {
Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow, Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow,
"[Generator].prototype.throw"); "[Generator].prototype.throw");
} }
...@@ -4191,11 +4182,10 @@ BUILTIN(ObjectProtoToString) { ...@@ -4191,11 +4182,10 @@ BUILTIN(ObjectProtoToString) {
// ES6 section 21.1 String Objects // ES6 section 21.1 String Objects
// ES6 section 21.1.3.1 String.prototype.charAt ( pos ) // ES6 section 21.1.3.1 String.prototype.charAt ( pos )
void Builtins::Generate_StringPrototypeCharAt( void Builtins::Generate_StringPrototypeCharAt(CodeStubAssembler* assembler) {
compiler::CodeStubAssembler* assembler) { typedef CodeStubAssembler::Label Label;
typedef compiler::CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* receiver = assembler->Parameter(0); Node* receiver = assembler->Parameter(0);
Node* position = assembler->Parameter(1); Node* position = assembler->Parameter(1);
...@@ -4287,10 +4277,10 @@ void Builtins::Generate_StringPrototypeCharAt( ...@@ -4287,10 +4277,10 @@ void Builtins::Generate_StringPrototypeCharAt(
// ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos ) // ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos )
void Builtins::Generate_StringPrototypeCharCodeAt( void Builtins::Generate_StringPrototypeCharCodeAt(
compiler::CodeStubAssembler* assembler) { CodeStubAssembler* assembler) {
typedef compiler::CodeStubAssembler::Label Label; typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node; typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Node* receiver = assembler->Parameter(0); Node* receiver = assembler->Parameter(0);
Node* position = assembler->Parameter(1); Node* position = assembler->Parameter(1);
...@@ -4987,11 +4977,10 @@ Handle<Code> MacroAssemblerBuilder(Isolate* isolate, ...@@ -4987,11 +4977,10 @@ Handle<Code> MacroAssemblerBuilder(Isolate* isolate,
Handle<Code> CodeStubAssemblerBuilder(Isolate* isolate, Handle<Code> CodeStubAssemblerBuilder(Isolate* isolate,
BuiltinDesc const* builtin_desc) { BuiltinDesc const* builtin_desc) {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
compiler::CodeStubAssembler assembler(isolate, &zone, builtin_desc->argc, CodeStubAssembler assembler(isolate, &zone, builtin_desc->argc,
builtin_desc->flags, builtin_desc->flags, builtin_desc->s_name);
builtin_desc->s_name);
// Generate the code/adaptor. // Generate the code/adaptor.
typedef void (*Generator)(compiler::CodeStubAssembler*); typedef void (*Generator)(CodeStubAssembler*);
Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator); Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator);
g(&assembler); g(&assembler);
return assembler.GenerateCode(); return assembler.GenerateCode();
...@@ -5147,8 +5136,8 @@ void Builtins::Generate_StackCheck(MacroAssembler* masm) { ...@@ -5147,8 +5136,8 @@ void Builtins::Generate_StackCheck(MacroAssembler* masm) {
namespace { namespace {
void ValidateSharedTypedArray(compiler::CodeStubAssembler* a, void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged,
compiler::Node* tagged, compiler::Node* context) { compiler::Node* context) {
using namespace compiler; using namespace compiler;
CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a), CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a),
not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a), not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a),
...@@ -5202,7 +5191,7 @@ void ValidateSharedTypedArray(compiler::CodeStubAssembler* a, ...@@ -5202,7 +5191,7 @@ void ValidateSharedTypedArray(compiler::CodeStubAssembler* a,
} }
// https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess
compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a, compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a,
compiler::Node* tagged, compiler::Node* tagged,
compiler::Node* context) { compiler::Node* context) {
using namespace compiler; using namespace compiler;
...@@ -5246,8 +5235,7 @@ compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a, ...@@ -5246,8 +5235,7 @@ compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a,
return var_result.value(); return var_result.value();
} }
void ValidateAtomicIndex(compiler::CodeStubAssembler* a, void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word,
compiler::Node* index_word,
compiler::Node* array_length_word, compiler::Node* array_length_word,
compiler::Node* context) { compiler::Node* context) {
using namespace compiler; using namespace compiler;
...@@ -5265,7 +5253,7 @@ void ValidateAtomicIndex(compiler::CodeStubAssembler* a, ...@@ -5265,7 +5253,7 @@ void ValidateAtomicIndex(compiler::CodeStubAssembler* a,
} // anonymous namespace } // anonymous namespace
void Builtins::Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* a) { void Builtins::Generate_AtomicsLoadCheck(CodeStubAssembler* a) {
using namespace compiler; using namespace compiler;
Isolate* isolate = a->isolate(); Isolate* isolate = a->isolate();
Node* array = a->Parameter(1); Node* array = a->Parameter(1);
......
...@@ -11,13 +11,9 @@ ...@@ -11,13 +11,9 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace compiler {
// Forward declarations. // Forward declarations.
class CodeStubAssembler; class CodeStubAssembler;
} // namespace compiler
// Specifies extra arguments required by a C++ builtin. // Specifies extra arguments required by a C++ builtin.
enum class BuiltinExtraArguments : uint8_t { enum class BuiltinExtraArguments : uint8_t {
kNone = 0u, kNone = 0u,
...@@ -591,11 +587,11 @@ class Builtins { ...@@ -591,11 +587,11 @@ class Builtins {
static void Generate_ArrayCode(MacroAssembler* masm); static void Generate_ArrayCode(MacroAssembler* masm);
// ES6 section 20.2.2.10 Math.ceil ( x ) // ES6 section 20.2.2.10 Math.ceil ( x )
static void Generate_MathCeil(compiler::CodeStubAssembler* assembler); static void Generate_MathCeil(CodeStubAssembler* assembler);
// ES6 section 20.2.2.11 Math.clz32 ( x ) // ES6 section 20.2.2.11 Math.clz32 ( x )
static void Generate_MathClz32(compiler::CodeStubAssembler* assembler); static void Generate_MathClz32(CodeStubAssembler* assembler);
// ES6 section 20.2.2.16 Math.floor ( x ) // ES6 section 20.2.2.16 Math.floor ( x )
static void Generate_MathFloor(compiler::CodeStubAssembler* assembler); static void Generate_MathFloor(CodeStubAssembler* assembler);
enum class MathMaxMinKind { kMax, kMin }; enum class MathMaxMinKind { kMax, kMin };
static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind); static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind);
// ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) // ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values )
...@@ -607,11 +603,11 @@ class Builtins { ...@@ -607,11 +603,11 @@ class Builtins {
Generate_MathMaxMin(masm, MathMaxMinKind::kMin); Generate_MathMaxMin(masm, MathMaxMinKind::kMin);
} }
// ES6 section 20.2.2.28 Math.round ( x ) // ES6 section 20.2.2.28 Math.round ( x )
static void Generate_MathRound(compiler::CodeStubAssembler* assembler); static void Generate_MathRound(CodeStubAssembler* assembler);
// ES6 section 20.2.2.32 Math.sqrt ( x ) // ES6 section 20.2.2.32 Math.sqrt ( x )
static void Generate_MathSqrt(compiler::CodeStubAssembler* assembler); static void Generate_MathSqrt(CodeStubAssembler* assembler);
// ES6 section 20.2.2.35 Math.trunc ( x ) // ES6 section 20.2.2.35 Math.trunc ( x )
static void Generate_MathTrunc(compiler::CodeStubAssembler* assembler); static void Generate_MathTrunc(CodeStubAssembler* assembler);
// ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case. // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case.
static void Generate_NumberConstructor(MacroAssembler* masm); static void Generate_NumberConstructor(MacroAssembler* masm);
...@@ -619,25 +615,19 @@ class Builtins { ...@@ -619,25 +615,19 @@ class Builtins {
static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm); static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm);
// ES6 section 25.3.1.2 Generator.prototype.next ( value ) // ES6 section 25.3.1.2 Generator.prototype.next ( value )
static void Generate_GeneratorPrototypeNext( static void Generate_GeneratorPrototypeNext(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
// ES6 section 25.3.1.3 Generator.prototype.return ( value ) // ES6 section 25.3.1.3 Generator.prototype.return ( value )
static void Generate_GeneratorPrototypeReturn( static void Generate_GeneratorPrototypeReturn(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
// ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) // ES6 section 25.3.1.4 Generator.prototype.throw ( exception )
static void Generate_GeneratorPrototypeThrow( static void Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
// ES6 section 19.1.3.2 Object.prototype.hasOwnProperty // ES6 section 19.1.3.2 Object.prototype.hasOwnProperty
static void Generate_ObjectHasOwnProperty( static void Generate_ObjectHasOwnProperty(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
// ES6 section 21.1.3.1 String.prototype.charAt ( pos ) // ES6 section 21.1.3.1 String.prototype.charAt ( pos )
static void Generate_StringPrototypeCharAt( static void Generate_StringPrototypeCharAt(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
// ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos ) // ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos )
static void Generate_StringPrototypeCharCodeAt( static void Generate_StringPrototypeCharCodeAt(CodeStubAssembler* assembler);
compiler::CodeStubAssembler* assembler);
static void Generate_StringConstructor(MacroAssembler* masm); static void Generate_StringConstructor(MacroAssembler* masm);
static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm); static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm);
...@@ -674,7 +664,7 @@ class Builtins { ...@@ -674,7 +664,7 @@ class Builtins {
static void Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm); static void Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm);
static void Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm); static void Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm);
static void Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* assembler); static void Generate_AtomicsLoadCheck(CodeStubAssembler* assembler);
static void InitBuiltinFunctionTable(); static void InitBuiltinFunctionTable();
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CODE_STUB_ASSEMBLER_H_
#define V8_CODE_STUB_ASSEMBLER_H_
#include "src/compiler/code-assembler.h"
#include "src/objects.h"
namespace v8 {
namespace internal {
class CallInterfaceDescriptor;
// Provides JavaScript-specific "macro-assembler" functionality on top of the
// CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler,
// it's possible to add JavaScript-specific useful CodeAssembler "macros"
// without modifying files in the compiler directory (and requiring a review
// from a compiler directory OWNER).
class CodeStubAssembler : public compiler::CodeAssembler {
public:
// Create with CallStub linkage.
// |result_size| specifies the number of results returned by the stub.
// TODO(rmcilroy): move result_size to the CallInterfaceDescriptor.
CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor,
Code::Flags flags, const char* name,
size_t result_size = 1);
// Create with JSCall linkage.
CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count,
Code::Flags flags, const char* name);
// Float64 operations.
compiler::Node* Float64Ceil(compiler::Node* x);
compiler::Node* Float64Floor(compiler::Node* x);
compiler::Node* Float64Round(compiler::Node* x);
compiler::Node* Float64Trunc(compiler::Node* x);
// Smi conversions.
compiler::Node* SmiToFloat64(compiler::Node* value);
compiler::Node* SmiFromWord32(compiler::Node* value);
compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); }
compiler::Node* SmiToWord32(compiler::Node* value);
// Smi operations.
compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b);
compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b);
// Check a value for smi-ness
compiler::Node* WordIsSmi(compiler::Node* a);
// Check that the value is a positive smi.
compiler::Node* WordIsPositiveSmi(compiler::Node* a);
void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true,
Label* if_false) {
BranchIf(SmiLessThan(a, b), if_true, if_false);
}
void BranchIfSmiLessThanOrEqual(compiler::Node* a, compiler::Node* b,
Label* if_true, Label* if_false) {
BranchIf(SmiLessThanOrEqual(a, b), if_true, if_false);
}
void BranchIfFloat64IsNaN(compiler::Node* value, Label* if_true,
Label* if_false) {
BranchIfFloat64Equal(value, value, if_false, if_true);
}
// Load an object pointer from a buffer that isn't in the heap.
compiler::Node* LoadBufferObject(compiler::Node* buffer, int offset,
MachineType rep = MachineType::AnyTagged());
// Load a field from an object on the heap.
compiler::Node* LoadObjectField(compiler::Node* object, int offset,
MachineType rep = MachineType::AnyTagged());
// Load the floating point value of a HeapNumber.
compiler::Node* LoadHeapNumberValue(compiler::Node* object);
// Load the Map of an HeapObject.
compiler::Node* LoadMap(compiler::Node* object);
// Load the instance type of an HeapObject.
compiler::Node* LoadInstanceType(compiler::Node* object);
// Load the elements backing store of a JSObject.
compiler::Node* LoadElements(compiler::Node* object);
// Load the length of a fixed array base instance.
compiler::Node* LoadFixedArrayBaseLength(compiler::Node* array);
// Load the bit field of a Map.
compiler::Node* LoadMapBitField(compiler::Node* map);
// Load bit field 2 of a map.
compiler::Node* LoadMapBitField2(compiler::Node* map);
// Load bit field 3 of a map.
compiler::Node* LoadMapBitField3(compiler::Node* map);
// Load the instance type of a map.
compiler::Node* LoadMapInstanceType(compiler::Node* map);
// Load the instance descriptors of a map.
compiler::Node* LoadMapDescriptors(compiler::Node* map);
// Load the hash field of a name.
compiler::Node* LoadNameHash(compiler::Node* name);
// Load the instance size of a Map.
compiler::Node* LoadMapInstanceSize(compiler::Node* map);
// Load an array element from a FixedArray.
compiler::Node* LoadFixedArrayElementInt32Index(compiler::Node* object,
compiler::Node* int32_index,
int additional_offset = 0);
compiler::Node* LoadFixedArrayElementSmiIndex(compiler::Node* object,
compiler::Node* smi_index,
int additional_offset = 0);
compiler::Node* LoadFixedArrayElementConstantIndex(compiler::Node* object,
int index);
// Store the floating point value of a HeapNumber.
compiler::Node* StoreHeapNumberValue(compiler::Node* object,
compiler::Node* value);
// Store a field to an object on the heap.
compiler::Node* StoreObjectFieldNoWriteBarrier(
compiler::Node* object, int offset, compiler::Node* value,
MachineRepresentation rep = MachineRepresentation::kTagged);
// Store the Map of an HeapObject.
compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object,
compiler::Node* map);
// Store an array element to a FixedArray.
compiler::Node* StoreFixedArrayElementInt32Index(compiler::Node* object,
compiler::Node* index,
compiler::Node* value);
compiler::Node* StoreFixedArrayElementNoWriteBarrier(compiler::Node* object,
compiler::Node* index,
compiler::Node* value);
// Allocate a HeapNumber without initializing its value.
compiler::Node* AllocateHeapNumber();
// Allocate a HeapNumber with a specific value.
compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value);
// Allocate a SeqOneByteString with the given length.
compiler::Node* AllocateSeqOneByteString(int length);
// Allocate a SeqTwoByteString with the given length.
compiler::Node* AllocateSeqTwoByteString(int length);
compiler::Node* TruncateTaggedToFloat64(compiler::Node* context,
compiler::Node* value);
compiler::Node* TruncateTaggedToWord32(compiler::Node* context,
compiler::Node* value);
// Truncate to int32 using JavaScript truncation mode.
compiler::Node* TruncateFloat64ToInt32(compiler::Node* value);
// Truncate the floating point value of a HeapNumber to an Int32.
compiler::Node* TruncateHeapNumberValueToWord32(compiler::Node* object);
// Conversions.
compiler::Node* ChangeFloat64ToTagged(compiler::Node* value);
compiler::Node* ChangeInt32ToTagged(compiler::Node* value);
compiler::Node* ChangeUint32ToTagged(compiler::Node* value);
// Type conversions.
// Throws a TypeError for {method_name} if {value} is not coercible to Object,
// or returns the {value} converted to a String otherwise.
compiler::Node* ToThisString(compiler::Node* context, compiler::Node* value,
char const* method_name);
// String helpers.
// Load a character from a String (might flatten a ConsString).
compiler::Node* StringCharCodeAt(compiler::Node* string,
compiler::Node* smi_index);
// Return the single character string with only {code}.
compiler::Node* StringFromCharCode(compiler::Node* code);
// Returns a node that is true if the given bit is set in |word32|.
template <typename T>
compiler::Node* BitFieldDecode(compiler::Node* word32) {
return BitFieldDecode(word32, T::kShift, T::kMask);
}
compiler::Node* BitFieldDecode(compiler::Node* word32, uint32_t shift,
uint32_t mask);
};
} // namespace internal
} // namespace v8
#endif // V8_CODE_STUB_ASSEMBLER_H_
This diff is collapsed.
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/assembler.h" #include "src/assembler.h"
#include "src/code-stub-assembler.h"
#include "src/codegen.h" #include "src/codegen.h"
#include "src/compiler/code-stub-assembler.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/ic/ic-state.h" #include "src/ic/ic-state.h"
#include "src/interface-descriptors.h" #include "src/interface-descriptors.h"
...@@ -396,10 +396,9 @@ class CodeStub BASE_EMBEDDED { ...@@ -396,10 +396,9 @@ class CodeStub BASE_EMBEDDED {
Handle<Code> GenerateCode() override; \ Handle<Code> GenerateCode() override; \
DEFINE_CODE_STUB(NAME, SUPER) DEFINE_CODE_STUB(NAME, SUPER)
#define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \ #define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER) \
public: \ public: \
void GenerateAssembly(compiler::CodeStubAssembler* assembler) \ void GenerateAssembly(CodeStubAssembler* assembler) const override; \
const override; \
DEFINE_CODE_STUB(NAME, SUPER) DEFINE_CODE_STUB(NAME, SUPER)
#define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \ #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \
...@@ -588,8 +587,7 @@ class TurboFanCodeStub : public CodeStub { ...@@ -588,8 +587,7 @@ class TurboFanCodeStub : public CodeStub {
protected: protected:
explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {} explicit TurboFanCodeStub(Isolate* isolate) : CodeStub(isolate) {}
virtual void GenerateAssembly( virtual void GenerateAssembly(CodeStubAssembler* assembler) const = 0;
compiler::CodeStubAssembler* assembler) const = 0;
private: private:
DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub); DEFINE_CODE_STUB_BASE(TurboFanCodeStub, CodeStub);
...@@ -910,7 +908,7 @@ class StoreInterceptorStub : public TurboFanCodeStub { ...@@ -910,7 +908,7 @@ class StoreInterceptorStub : public TurboFanCodeStub {
public: public:
explicit StoreInterceptorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit StoreInterceptorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
void GenerateAssembly(compiler::CodeStubAssembler* assember) const override; void GenerateAssembly(CodeStubAssembler* assember) const override;
Code::Kind GetCodeKind() const override { return Code::HANDLER; } Code::Kind GetCodeKind() const override { return Code::HANDLER; }
ExtraICState GetExtraICState() const override { return Code::STORE_IC; } ExtraICState GetExtraICState() const override { return Code::STORE_IC; }
...@@ -2677,7 +2675,7 @@ class AllocateHeapNumberStub : public TurboFanCodeStub { ...@@ -2677,7 +2675,7 @@ class AllocateHeapNumberStub : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {} : TurboFanCodeStub(isolate) {}
void InitializeDescriptor(CodeStubDescriptor* descriptor) override; void InitializeDescriptor(CodeStubDescriptor* descriptor) override;
void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; void GenerateAssembly(CodeStubAssembler* assembler) const override;
DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateHeapNumber); DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateHeapNumber);
DEFINE_CODE_STUB(AllocateHeapNumber, TurboFanCodeStub); DEFINE_CODE_STUB(AllocateHeapNumber, TurboFanCodeStub);
...@@ -2689,7 +2687,7 @@ class AllocateMutableHeapNumberStub : public TurboFanCodeStub { ...@@ -2689,7 +2687,7 @@ class AllocateMutableHeapNumberStub : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {} : TurboFanCodeStub(isolate) {}
void InitializeDescriptor(CodeStubDescriptor* descriptor) override; void InitializeDescriptor(CodeStubDescriptor* descriptor) override;
void GenerateAssembly(compiler::CodeStubAssembler* assembler) const override; void GenerateAssembly(CodeStubAssembler* assembler) const override;
DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateMutableHeapNumber); DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateMutableHeapNumber);
DEFINE_CODE_STUB(AllocateMutableHeapNumber, TurboFanCodeStub); DEFINE_CODE_STUB(AllocateMutableHeapNumber, TurboFanCodeStub);
...@@ -2702,8 +2700,7 @@ class AllocateMutableHeapNumberStub : public TurboFanCodeStub { ...@@ -2702,8 +2700,7 @@ class AllocateMutableHeapNumberStub : public TurboFanCodeStub {
: TurboFanCodeStub(isolate) {} \ : TurboFanCodeStub(isolate) {} \
\ \
void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \ void InitializeDescriptor(CodeStubDescriptor* descriptor) override; \
void GenerateAssembly( \ void GenerateAssembly(CodeStubAssembler* assembler) const override; \
compiler::CodeStubAssembler* assembler) const override; \
\ \
DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate##Type); \ DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate##Type); \
DEFINE_CODE_STUB(Allocate##Type, TurboFanCodeStub); \ DEFINE_CODE_STUB(Allocate##Type, TurboFanCodeStub); \
......
This diff is collapsed.
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#include "src/fast-accessor-assembler.h" #include "src/fast-accessor-assembler.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/code-stub-assembler.h"
#include "src/code-stubs.h" // For CallApiCallbackStub. #include "src/code-stubs.h" // For CallApiCallbackStub.
#include "src/compiler/code-stub-assembler.h"
#include "src/handles-inl.h" #include "src/handles-inl.h"
#include "src/objects.h" // For FAA::LoadInternalField impl. #include "src/objects.h" // For FAA::LoadInternalField impl.
using v8::internal::compiler::CodeStubAssembler; using v8::internal::CodeStubAssembler;
using v8::internal::compiler::Node; using v8::internal::compiler::Node;
namespace v8 { namespace v8 {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "src/handles.h" #include "src/handles.h"
// For CodeStubAssembler::Label. (We cannot forward-declare inner classes.) // For CodeStubAssembler::Label. (We cannot forward-declare inner classes.)
#include "src/compiler/code-stub-assembler.h" #include "src/code-stub-assembler.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -73,9 +73,9 @@ class FastAccessorAssembler { ...@@ -73,9 +73,9 @@ class FastAccessorAssembler {
private: private:
ValueId FromRaw(compiler::Node* node); ValueId FromRaw(compiler::Node* node);
LabelId FromRaw(compiler::CodeStubAssembler::Label* label); LabelId FromRaw(CodeStubAssembler::Label* label);
compiler::Node* FromId(ValueId value) const; compiler::Node* FromId(ValueId value) const;
compiler::CodeStubAssembler::Label* FromId(LabelId value) const; CodeStubAssembler::Label* FromId(LabelId value) const;
void Clear(); void Clear();
Zone* zone() { return &zone_; } Zone* zone() { return &zone_; }
...@@ -83,13 +83,13 @@ class FastAccessorAssembler { ...@@ -83,13 +83,13 @@ class FastAccessorAssembler {
Zone zone_; Zone zone_;
Isolate* isolate_; Isolate* isolate_;
base::SmartPointer<compiler::CodeStubAssembler> assembler_; base::SmartPointer<CodeStubAssembler> assembler_;
// To prevent exposing the RMA internals to the outside world, we'll map // To prevent exposing the RMA internals to the outside world, we'll map
// Node + Label pointers integers wrapped in ValueId and LabelId instances. // Node + Label pointers integers wrapped in ValueId and LabelId instances.
// These vectors maintain this mapping. // These vectors maintain this mapping.
std::vector<compiler::Node*> nodes_; std::vector<compiler::Node*> nodes_;
std::vector<compiler::CodeStubAssembler::Label*> labels_; std::vector<CodeStubAssembler::Label*> labels_;
// Remember the current state for easy error checking. (We prefer to be // Remember the current state for easy error checking. (We prefer to be
// strict as this class will be exposed at the API.) // strict as this class will be exposed at the API.)
......
...@@ -25,10 +25,9 @@ using compiler::Node; ...@@ -25,10 +25,9 @@ using compiler::Node;
InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone,
Bytecode bytecode, Bytecode bytecode,
OperandScale operand_scale) OperandScale operand_scale)
: compiler::CodeStubAssembler(isolate, zone, : CodeStubAssembler(isolate, zone, InterpreterDispatchDescriptor(isolate),
InterpreterDispatchDescriptor(isolate), Code::ComputeFlags(Code::BYTECODE_HANDLER),
Code::ComputeFlags(Code::BYTECODE_HANDLER), Bytecodes::ToString(bytecode), 0),
Bytecodes::ToString(bytecode), 0),
bytecode_(bytecode), bytecode_(bytecode),
operand_scale_(operand_scale), operand_scale_(operand_scale),
accumulator_(this, MachineRepresentation::kTagged), accumulator_(this, MachineRepresentation::kTagged),
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/base/smart-pointers.h" #include "src/base/smart-pointers.h"
#include "src/builtins.h" #include "src/builtins.h"
#include "src/compiler/code-stub-assembler.h" #include "src/code-stub-assembler.h"
#include "src/frames.h" #include "src/frames.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
#include "src/runtime/runtime.h" #include "src/runtime/runtime.h"
...@@ -17,7 +17,7 @@ namespace v8 { ...@@ -17,7 +17,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace interpreter { namespace interpreter {
class InterpreterAssembler : public compiler::CodeStubAssembler { class InterpreterAssembler : public CodeStubAssembler {
public: public:
InterpreterAssembler(Isolate* isolate, Zone* zone, Bytecode bytecode, InterpreterAssembler(Isolate* isolate, Zone* zone, Bytecode bytecode,
OperandScale operand_scale); OperandScale operand_scale);
......
...@@ -455,6 +455,8 @@ ...@@ -455,6 +455,8 @@
'../../src/checks.h', '../../src/checks.h',
'../../src/code-factory.cc', '../../src/code-factory.cc',
'../../src/code-factory.h', '../../src/code-factory.h',
'../../src/code-stub-assembler.cc',
'../../src/code-stub-assembler.h',
'../../src/code-stubs.cc', '../../src/code-stubs.cc',
'../../src/code-stubs.h', '../../src/code-stubs.h',
'../../src/code-stubs-hydrogen.cc', '../../src/code-stubs-hydrogen.cc',
...@@ -493,8 +495,8 @@ ...@@ -493,8 +495,8 @@
'../../src/compiler/code-generator-impl.h', '../../src/compiler/code-generator-impl.h',
'../../src/compiler/code-generator.cc', '../../src/compiler/code-generator.cc',
'../../src/compiler/code-generator.h', '../../src/compiler/code-generator.h',
'../../src/compiler/code-stub-assembler.cc', '../../src/compiler/code-assembler.cc',
'../../src/compiler/code-stub-assembler.h', '../../src/compiler/code-assembler.h',
'../../src/compiler/common-node-cache.cc', '../../src/compiler/common-node-cache.cc',
'../../src/compiler/common-node-cache.h', '../../src/compiler/common-node-cache.h',
'../../src/compiler/common-operator-reducer.cc', '../../src/compiler/common-operator-reducer.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment