Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/compiler/code-stub-assembler.h

Issue 1649723002: [compiler] Extend the functionality of CodeStubAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Latest Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/code-stub-assembler.cc » ('j') | src/compiler/code-stub-assembler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/code-stub-assembler.h
diff --git a/src/compiler/code-stub-assembler.h b/src/compiler/code-stub-assembler.h
index 6c2e299de95974c3a9502689b5398cbda08100bf..dbcb37f4cb36590fd655258e0b3f7cd0088b249e 100644
--- a/src/compiler/code-stub-assembler.h
+++ b/src/compiler/code-stub-assembler.h
@@ -5,11 +5,16 @@
#ifndef V8_COMPILER_CODE_STUB_ASSEMBLER_H_
#define V8_COMPILER_CODE_STUB_ASSEMBLER_H_
+#include <map>
+
// Clients of this interface shouldn't depend on lots of compiler internals.
// Do not include anything from src/compiler here!
#include "src/allocation.h"
#include "src/builtins.h"
+#include "src/heap/heap.h"
+#include "src/machine-type.h"
#include "src/runtime/runtime.h"
+#include "src/zone-containers.h"
namespace v8 {
namespace internal {
@@ -25,8 +30,41 @@ class Graph;
class Node;
class Operator;
class RawMachineAssembler;
+class RawMachineLabel;
class Schedule;
+#define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \
+ V(IntPtrAdd) \
+ V(IntPtrSub) \
+ V(Int32Add) \
+ V(Int32Sub) \
+ V(Int32Mul) \
+ V(WordEqual) \
+ V(WordNotEqual) \
+ V(WordOr) \
+ V(WordAnd) \
+ V(WordXor) \
+ V(WordShl) \
+ V(WordShr) \
+ V(WordSar) \
+ V(WordRor) \
+ V(Word32Equal) \
+ V(Word32NotEqual) \
+ V(Word32Or) \
+ V(Word32And) \
+ V(Word32Xor) \
+ V(Word32Shr) \
+ V(Word32Sar) \
+ V(Word32Ror) \
+ V(Word64Equal) \
+ V(Word64NotEqual) \
+ V(Word64Or) \
+ V(Word64And) \
+ V(Word64Xor) \
+ V(Word64Shr) \
+ V(Word64Sar) \
+ V(Word64Ror)
+
class CodeStubAssembler {
public:
CodeStubAssembler(Isolate* isolate, Zone* zone,
@@ -36,40 +74,112 @@ class CodeStubAssembler {
Handle<Code> GenerateCode();
+ class Label;
+ class Variable {
+ public:
+ explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep);
+ void Bind(Node* value) { impl_->value_ = value; }
+ Node* value() const {
+ DCHECK(impl_->value_ != nullptr);
Michael Starzinger 2016/02/01 16:04:12 nit: DCHECK_NOT_NULL
danno 2016/02/02 07:52:55 Done.
+ return impl_->value_;
+ }
+ MachineRepresentation rep() const { return impl_->rep_; }
+ bool IsBound() const { return impl_->value_ != nullptr; }
+
+ private:
+ friend class CodeStubAssembler;
+ // The core implementation of Variable is stored through an indirection so
+ // that it can outlive the often block-scoped Variable declarations. This is
+ // needed to ensure that variable binding and merging through phis can
+ // properly be verified.
+ class Impl : public ZoneObject {
Michael Starzinger 2016/02/01 16:04:12 nit: Does this need to be a nested class within th
danno 2016/02/02 07:52:55 Done.
+ public:
+ explicit Impl(MachineRepresentation rep) : value_(nullptr), rep_(rep) {}
+ Node* value_;
+ MachineRepresentation rep_;
+ };
+ Impl* impl_;
+ };
+
+ //
Michael Starzinger 2016/02/01 16:04:12 nit: A loon separator line could have a higher vis
danno 2016/02/02 07:52:55 Done.
+ // BASE ASSEMBLER
+ //
+
// Constants.
Node* Int32Constant(int value);
Node* IntPtrConstant(intptr_t value);
Node* NumberConstant(double value);
Node* HeapConstant(Handle<HeapObject> object);
Node* BooleanConstant(bool value);
+ Node* ExternalConstant(ExternalReference address);
Node* Parameter(int value);
void Return(Node* value);
+ void Bind(Label* label);
+ void Goto(Label* label);
+ void Branch(Node* condition, Label* true_label, Label* false_label);
+
+ void Switch(Node* index, Label* default_label, int32_t* case_values,
+ Label** case_labels, size_t case_count);
+
+ // Access to the frame pointer
+ Node* LoadFramePointer();
+ Node* LoadParentFramePointer();
+
+// Basic arithmetic operations.
+#define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b);
+ CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP)
+#undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP
+
+ Node* WordShl(Node* value, int shift);
+
+ // Calls
+ Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1);
+ Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1,
+ Node* arg2);
+
+ Node* TailCallRuntime(Runtime::FunctionId function_id, Node* arg1,
+ Node* context);
+ Node* TailCallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2,
+ Node* context);
+ Node* TailCallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2,
+ Node* arg3, Node* context);
+ Node* TailCallRuntime(Runtime::FunctionId function_id, Node* arg1, Node* arg2,
+ Node* arg3, Node* arg4, Node* context);
+
+ Node* TailCallStub(CodeStub& stub, Node** args);
+ Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target,
+ Node** args);
+
+ //
+ // MACROS
Michael Starzinger 2016/02/01 16:04:12 nit: Likewise.
danno 2016/02/02 07:52:55 Done.
+ //
+
// Tag and untag Smi values.
Node* SmiTag(Node* value);
Node* SmiUntag(Node* value);
- // Basic arithmetic operations.
- Node* IntPtrAdd(Node* a, Node* b);
- Node* IntPtrSub(Node* a, Node* b);
- Node* WordShl(Node* value, int shift);
+ // Load a value from the root array.
+ Node* LoadRoot(Heap::RootListIndex root_index);
+
+ // Check a value for smi-ness
+ Node* WordIsSmi(Node* a);
+ // Load an object pointer from a buffer that isn't in the heap.
+ Node* LoadBufferObject(Node* buffer, int offset);
// Load a field from an object on the heap.
Node* LoadObjectField(Node* object, int offset);
- // Call runtime function.
- Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1);
- Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1,
- Node* arg2);
-
- Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context,
- Node* arg1);
- Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context,
- Node* arg1, Node* arg2);
+ // Load an array element from a FixedArray.
+ Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index,
+ int additional_offset = 0);
+ Node* LoadFixedArrayElementConstantIndex(Node* object, int index);
private:
friend class CodeStubAssemblerTester;
+ friend class Label;
Michael Starzinger 2016/02/01 16:04:12 nit: Are these friend declarations needed? I was a
danno 2016/02/02 07:52:55 Done.
+ friend class Variable;
Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args);
Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args);
@@ -85,10 +195,38 @@ class CodeStubAssembler {
Code::Flags flags_;
const char* name_;
bool code_generated_;
+ ZoneVector<Variable::Impl*> vars_;
Michael Starzinger 2016/02/01 16:04:12 nit: s/vars/variables/
danno 2016/02/02 07:52:55 Done.
DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler);
};
+class CodeStubAssembler::Label {
+ public:
+ explicit Label(CodeStubAssembler* assembler);
+ Label(CodeStubAssembler* assembler, int merged_variable_count,
+ CodeStubAssembler::Variable** merged_variables);
+ Label(CodeStubAssembler* assembler,
+ CodeStubAssembler::Variable* merged_variable);
+ ~Label() {}
+
+ private:
+ friend class CodeStubAssembler;
+
+ void Bind();
+ void MergeVariables();
+
+ bool bound_;
+ size_t merge_count_;
+ CodeStubAssembler* assembler_;
+ RawMachineLabel* label_;
+ // Map of variables that need to be merged to their phi nodes (or placeholders
+ // for those phis).
+ std::map<Variable::Impl*, Node*> variable_phis_;
+ // Map of variables to the list of value nodes that have been added from each
+ // merge path in their order of merging.
+ std::map<Variable::Impl*, std::vector<Node*>> variable_merges_;
+};
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « no previous file | src/compiler/code-stub-assembler.cc » ('j') | src/compiler/code-stub-assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698