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

Side by Side Diff: src/compiler/fast-accessor-assembler.cc

Issue 1474543004: Implement Fast Accessor Builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/compiler/fast-accessor-assembler.h"
6
7 #include "src/base/logging.h"
8 #include "src/compiler/graph.h"
9 #include "src/compiler/linkage.h"
10 #include "src/compiler/pipeline.h"
11 #include "src/compiler/raw-machine-assembler.h"
12 #include "src/compiler/schedule.h"
13 #include "src/compiler/verifier.h"
14 #include "src/handles-inl.h"
15
16 namespace v8 {
17 namespace internal {
18 namespace compiler {
19
20 FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate)
21 : zone_(),
22 assembler_(new RawMachineAssembler(
23 isolate, new (zone()) Graph(zone()),
24 Linkage::GetJSCallDescriptor(&zone_, false, 1,
25 CallDescriptor::kNoFlags))),
26 state_(BUILDING) {}
27
28
29 FastAccessorAssembler::~FastAccessorAssembler() {}
30
31
32 FastAccessorAssembler::ValueId FastAccessorAssembler::IntegerConstant(
33 int const_value) {
34 CHECK_EQ(BUILDING, state_);
35 return FromNode(assembler_->NumberConstant(const_value));
36 }
37
38
39 FastAccessorAssembler::ValueId FastAccessorAssembler::GetParameter(
40 size_t parameter_no) {
41 CHECK_EQ(BUILDING, state_);
42 return FromNode(assembler_->Parameter(parameter_no));
43 }
44
45
46 FastAccessorAssembler::ValueId FastAccessorAssembler::LoadValue(
47 FastAccessorAssembler::ValueId value, int offset) {
48 CHECK_EQ(BUILDING, state_);
49 return FromNode(assembler_->Load(kMachIntPtr, FromValue(value),
50 assembler_->IntPtrConstant(offset)));
51 }
52
53
54 void FastAccessorAssembler::ReturnValue(ValueId value) {
55 assembler_->Return(FromValue(value));
56 }
57
58
59 void FastAccessorAssembler::CheckNotNullOrReturnNull(ValueId value) {
60 CHECK_EQ(BUILDING, state_);
61 RawMachineAssembler::Label pass, fail;
62 assembler_->Branch(
63 assembler_->IntPtrEqual(assembler_->Load(kMachIntPtr, FromValue(value)),
64 assembler_->IntPtrConstant(0)),
65 &pass, &fail);
66 assembler_->Bind(&fail);
67 assembler_->Return(assembler_->NullConstant());
68 assembler_->Bind(&pass);
69 }
70
71
72 Handle<Code> FastAccessorAssembler::Build() {
73 CHECK_EQ(BUILDING, state_);
74
75 // Cleanup: We no longer need this memory.
76 nodes_.clear();
epertoso 2015/11/25 10:31:15 These two calls to clear() don't do what you seem
vogelheim 2015/11/26 14:41:43 You're technically correct... :-) Well.. I'm tryi
77 labels_.clear();
78
79 // Export the schedule and call the compiler.
80 CompilationInfo info("FastAccessorAssembler", assembler_->isolate(), zone());
81 Schedule* schedule = assembler_->Export();
82 Handle<Code> code = Pipeline::GenerateCodeForTesting(
epertoso 2015/11/25 10:31:15 nit: add a TODO here, we should probably not use a
vogelheim 2015/11/26 14:41:43 Yes. src/compiler/* owners will have an opinion on
83 &info, assembler_->call_descriptor(), assembler_->graph(), schedule);
84
85 {
86 OFStream os(stdout);
87 os << "schedule\n" << *schedule;
88 os << "code\n";
89 code->Print();
90 }
91
92 // Update state & return.
93 state_ = !code.is_null() ? BUILT : ERROR;
94 return code;
95 }
96
97
98 CallDescriptor* FastAccessorAssembler::GetCallDescriptor() const {
99 CHECK_EQ(BUILT, state_);
100 return assembler_->call_descriptor();
101 }
102
103
104 FastAccessorAssembler::ValueId FastAccessorAssembler::FromNode(Node* node) {
105 if (labels_.size() > nodes_.size()) {
106 nodes_.resize(labels_.size(), nullptr);
epertoso 2015/11/25 10:31:15 Why?
vogelheim 2015/11/26 14:41:43 So... I'm trying to hide the RawMachineAssembler i
107 }
108
109 nodes_.push_back(node);
110 return nodes_.size() - 1;
111 }
112
113
114 Node* FastAccessorAssembler::FromValue(
115 FastAccessorAssembler::ValueId value) const {
116 CHECK_LT(value, nodes_.size());
117 CHECK_NOT_NULL(nodes_.at(value));
118 return nodes_.at(value);
119 }
120
121 } // namespace compiler
122 } // namespace internal
123 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698