Commit 6c8fc936 authored by vogelheim's avatar vogelheim Committed by Commit bot

Move FastAccessorAssembler from RawMachineAssembler to CodeStubAssembler.

(The goal is to have CodeStubAssembler be the sole assembler-like user of
the TF compiler pipeline; with RMA being a private implementation detail
and FAA being a client.)

BUG=chromium:508898
LOG=Y

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

Cr-Commit-Position: refs/heads/master@{#34852}
parent ef6585d8
...@@ -760,8 +760,6 @@ source_set("v8_base") { ...@@ -760,8 +760,6 @@ source_set("v8_base") {
"src/compiler/escape-analysis.h", "src/compiler/escape-analysis.h",
"src/compiler/escape-analysis-reducer.cc", "src/compiler/escape-analysis-reducer.cc",
"src/compiler/escape-analysis-reducer.h", "src/compiler/escape-analysis-reducer.h",
"src/compiler/fast-accessor-assembler.cc",
"src/compiler/fast-accessor-assembler.h",
"src/compiler/frame.cc", "src/compiler/frame.cc",
"src/compiler/frame.h", "src/compiler/frame.h",
"src/compiler/frame-elider.cc", "src/compiler/frame-elider.cc",
...@@ -1023,6 +1021,8 @@ source_set("v8_base") { ...@@ -1023,6 +1021,8 @@ source_set("v8_base") {
"src/extensions/trigger-failure-extension.h", "src/extensions/trigger-failure-extension.h",
"src/factory.cc", "src/factory.cc",
"src/factory.h", "src/factory.h",
"src/fast-accessor-assembler.cc",
"src/fast-accessor-assembler.h",
"src/fast-dtoa.cc", "src/fast-dtoa.cc",
"src/fast-dtoa.h", "src/fast-dtoa.h",
"src/field-index.h", "src/field-index.h",
......
...@@ -21,7 +21,4 @@ specific_include_rules = { ...@@ -21,7 +21,4 @@ specific_include_rules = {
"d8\.cc": [ "d8\.cc": [
"+include/libplatform/libplatform.h", "+include/libplatform/libplatform.h",
], ],
"api-experimental\.cc": [
"+src/compiler/fast-accessor-assembler.h",
],
} }
...@@ -11,20 +11,17 @@ ...@@ -11,20 +11,17 @@
#include "include/v8.h" #include "include/v8.h"
#include "include/v8-experimental.h" #include "include/v8-experimental.h"
#include "src/api.h" #include "src/api.h"
#include "src/compiler/fast-accessor-assembler.h" #include "src/fast-accessor-assembler.h"
namespace { namespace {
v8::internal::FastAccessorAssembler* FromApi(
v8::internal::compiler::FastAccessorAssembler* FromApi(
v8::experimental::FastAccessorBuilder* builder) { v8::experimental::FastAccessorBuilder* builder) {
return reinterpret_cast<v8::internal::compiler::FastAccessorAssembler*>( return reinterpret_cast<v8::internal::FastAccessorAssembler*>(builder);
builder);
} }
v8::experimental::FastAccessorBuilder* FromInternal( v8::experimental::FastAccessorBuilder* FromInternal(
v8::internal::compiler::FastAccessorAssembler* fast_accessor_assembler) { v8::internal::FastAccessorAssembler* fast_accessor_assembler) {
return reinterpret_cast<v8::experimental::FastAccessorBuilder*>( return reinterpret_cast<v8::experimental::FastAccessorBuilder*>(
fast_accessor_assembler); fast_accessor_assembler);
} }
...@@ -57,8 +54,8 @@ namespace experimental { ...@@ -57,8 +54,8 @@ namespace experimental {
FastAccessorBuilder* FastAccessorBuilder::New(Isolate* isolate) { FastAccessorBuilder* FastAccessorBuilder::New(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal::compiler::FastAccessorAssembler* faa = internal::FastAccessorAssembler* faa =
new internal::compiler::FastAccessorAssembler(i_isolate); new internal::FastAccessorAssembler(i_isolate);
return FromInternal(faa); return FromInternal(faa);
} }
......
...@@ -28,24 +28,27 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, ...@@ -28,24 +28,27 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor, const CallInterfaceDescriptor& descriptor,
Code::Flags flags, const char* name, Code::Flags flags, const char* name,
size_t result_size) size_t result_size)
: raw_assembler_(new RawMachineAssembler( : CodeStubAssembler(
isolate, new (zone) Graph(zone), isolate, zone,
Linkage::GetStubCallDescriptor( Linkage::GetStubCallDescriptor(
isolate, zone, descriptor, descriptor.GetStackParameterCount(), isolate, zone, descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties, CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size))), MachineType::AnyTagged(), result_size),
flags_(flags), flags, name) {}
name_(name),
code_generated_(false),
variables_(zone) {}
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
int parameter_count, Code::Flags flags, int parameter_count, Code::Flags flags,
const char* name) const char* name)
: raw_assembler_(new RawMachineAssembler( : CodeStubAssembler(isolate, zone, Linkage::GetJSCallDescriptor(
isolate, new (zone) Graph(zone), zone, false, parameter_count,
Linkage::GetJSCallDescriptor(zone, false, parameter_count, CallDescriptor::kNoFlags),
CallDescriptor::kNoFlags))), flags, name) {}
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
CallDescriptor* call_descriptor,
Code::Flags flags, const char* name)
: raw_assembler_(new RawMachineAssembler(isolate, new (zone) Graph(zone),
call_descriptor)),
flags_(flags), flags_(flags),
name_(name), name_(name),
code_generated_(false), code_generated_(false),
...@@ -113,11 +116,18 @@ Node* CodeStubAssembler::HeapNumberMapConstant() { ...@@ -113,11 +116,18 @@ Node* CodeStubAssembler::HeapNumberMapConstant() {
return HeapConstant(isolate()->factory()->heap_number_map()); return HeapConstant(isolate()->factory()->heap_number_map());
} }
Node* CodeStubAssembler::NullConstant() {
return LoadRoot(Heap::kNullValueRootIndex);
}
Node* CodeStubAssembler::UndefinedConstant() {
return LoadRoot(Heap::kUndefinedValueRootIndex);
}
Node* CodeStubAssembler::Parameter(int value) { Node* CodeStubAssembler::Parameter(int value) {
return raw_assembler_->Parameter(value); return raw_assembler_->Parameter(value);
} }
void CodeStubAssembler::Return(Node* value) { void CodeStubAssembler::Return(Node* value) {
return raw_assembler_->Return(value); return raw_assembler_->Return(value);
} }
...@@ -211,13 +221,14 @@ Node* CodeStubAssembler::WordIsSmi(Node* a) { ...@@ -211,13 +221,14 @@ Node* CodeStubAssembler::WordIsSmi(Node* a) {
IntPtrConstant(0)); IntPtrConstant(0));
} }
Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset) { Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
return raw_assembler_->Load(MachineType::AnyTagged(), buffer, MachineType rep) {
IntPtrConstant(offset)); return raw_assembler_->Load(rep, buffer, IntPtrConstant(offset));
} }
Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { Node* CodeStubAssembler::LoadObjectField(Node* object, int offset,
return raw_assembler_->Load(MachineType::AnyTagged(), object, MachineType rep) {
return raw_assembler_->Load(rep, object,
IntPtrConstant(offset - kHeapObjectTag)); IntPtrConstant(offset - kHeapObjectTag));
} }
......
...@@ -148,6 +148,8 @@ class CodeStubAssembler { ...@@ -148,6 +148,8 @@ class CodeStubAssembler {
Node* Float64Constant(double value); Node* Float64Constant(double value);
Node* BooleanMapConstant(); Node* BooleanMapConstant();
Node* HeapNumberMapConstant(); Node* HeapNumberMapConstant();
Node* NullConstant();
Node* UndefinedConstant();
Node* Parameter(int value); Node* Parameter(int value);
void Return(Node* value); void Return(Node* value);
...@@ -268,9 +270,11 @@ class CodeStubAssembler { ...@@ -268,9 +270,11 @@ class CodeStubAssembler {
Node* WordIsSmi(Node* a); Node* WordIsSmi(Node* a);
// Load an object pointer from a buffer that isn't in the heap. // Load an object pointer from a buffer that isn't in the heap.
Node* LoadBufferObject(Node* buffer, int offset); Node* LoadBufferObject(Node* buffer, int offset,
MachineType rep = MachineType::AnyTagged());
// Load a field from an object on the heap. // Load a field from an object on the heap.
Node* LoadObjectField(Node* object, int offset); Node* LoadObjectField(Node* object, int offset,
MachineType rep = MachineType::AnyTagged());
// Load the floating point value of a HeapNumber. // Load the floating point value of a HeapNumber.
Node* LoadHeapNumberValue(Node* object); Node* LoadHeapNumberValue(Node* object);
// Load the bit field of a Map. // Load the bit field of a Map.
...@@ -338,6 +342,10 @@ class CodeStubAssembler { ...@@ -338,6 +342,10 @@ class CodeStubAssembler {
private: private:
friend class CodeStubAssemblerTester; friend class CodeStubAssemblerTester;
CodeStubAssembler(Isolate* isolate, Zone* zone,
CallDescriptor* call_descriptor, Code::Flags flags,
const char* name);
Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args);
Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args);
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_
#define V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ #define V8_FAST_ACCESSOR_ASSEMBLER_H_
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
// Clients of this interface shouldn't depend on lots of compiler internals.
// Do not include anything from src/compiler here!
#include "include/v8-experimental.h" #include "include/v8-experimental.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/base/smart-pointers.h" #include "src/base/smart-pointers.h"
#include "src/handles.h" #include "src/handles.h"
// For CodeStubAssembler::Label. (We cannot forward-declare inner classes.)
#include "src/compiler/code-stub-assembler.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -24,11 +24,8 @@ class Isolate; ...@@ -24,11 +24,8 @@ class Isolate;
class Zone; class Zone;
namespace compiler { namespace compiler {
class Node; class Node;
class RawMachineAssembler; }
class RawMachineLabel;
// This interface "exports" an aggregated subset of RawMachineAssembler, for // This interface "exports" an aggregated subset of RawMachineAssembler, for
// use by the API to implement Fast Dom Accessors. // use by the API to implement Fast Dom Accessors.
...@@ -75,21 +72,24 @@ class FastAccessorAssembler { ...@@ -75,21 +72,24 @@ class FastAccessorAssembler {
MaybeHandle<Code> Build(); MaybeHandle<Code> Build();
private: private:
ValueId FromRaw(Node* node); ValueId FromRaw(compiler::Node* node);
LabelId FromRaw(RawMachineLabel* label); LabelId FromRaw(compiler::CodeStubAssembler::Label* label);
Node* FromId(ValueId value) const; compiler::Node* FromId(ValueId value) const;
RawMachineLabel* FromId(LabelId value) const; compiler::CodeStubAssembler::Label* FromId(LabelId value) const;
void Clear();
Zone* zone() { return &zone_; } Zone* zone() { return &zone_; }
Isolate* isolate() const { return isolate_; }
Zone zone_; Zone zone_;
base::SmartPointer<RawMachineAssembler> assembler_; Isolate* isolate_;
base::SmartPointer<compiler::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<Node*> nodes_; std::vector<compiler::Node*> nodes_;
std::vector<RawMachineLabel*> labels_; std::vector<compiler::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.)
...@@ -98,8 +98,7 @@ class FastAccessorAssembler { ...@@ -98,8 +98,7 @@ class FastAccessorAssembler {
DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler);
}; };
} // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
#endif // V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_
...@@ -586,8 +586,6 @@ ...@@ -586,8 +586,6 @@
'../../src/compiler/escape-analysis.h', '../../src/compiler/escape-analysis.h',
"../../src/compiler/escape-analysis-reducer.cc", "../../src/compiler/escape-analysis-reducer.cc",
"../../src/compiler/escape-analysis-reducer.h", "../../src/compiler/escape-analysis-reducer.h",
'../../src/compiler/fast-accessor-assembler.cc',
'../../src/compiler/fast-accessor-assembler.h',
'../../src/compiler/frame.cc', '../../src/compiler/frame.cc',
'../../src/compiler/frame.h', '../../src/compiler/frame.h',
'../../src/compiler/frame-elider.cc', '../../src/compiler/frame-elider.cc',
...@@ -851,6 +849,8 @@ ...@@ -851,6 +849,8 @@
'../../src/extensions/trigger-failure-extension.h', '../../src/extensions/trigger-failure-extension.h',
'../../src/factory.cc', '../../src/factory.cc',
'../../src/factory.h', '../../src/factory.h',
'../../src/fast-accessor-assembler.cc',
'../../src/fast-accessor-assembler.h',
'../../src/fast-dtoa.cc', '../../src/fast-dtoa.cc',
'../../src/fast-dtoa.h', '../../src/fast-dtoa.h',
'../../src/field-index.h', '../../src/field-index.h',
......
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