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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 12220074: Compile FastCloneShallowObjectStub using Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implemented port to ARM. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 explicit CodeStubGraphBuilder(Stub* stub) 125 explicit CodeStubGraphBuilder(Stub* stub)
126 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} 126 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {}
127 127
128 protected: 128 protected:
129 virtual void BuildCodeStub(); 129 virtual void BuildCodeStub();
130 Stub* casted_stub() { return static_cast<Stub*>(stub()); } 130 Stub* casted_stub() { return static_cast<Stub*>(stub()); }
131 }; 131 };
132 132
133 133
134 template <> 134 template <>
135 void CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
136 Zone* zone = this->zone();
137 Factory* factory = isolate()->factory();
138
139 HInstruction* boilerplate =
140 AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
141 GetParameter(1),
142 NULL,
143 FAST_ELEMENTS));
144
145 CheckBuilder builder(this);
146 builder.CheckNotUndefined(boilerplate);
147
148 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
149 HValue* boilerplate_size =
150 AddInstruction(new(zone) HInstanceSize(boilerplate));
151 HValue* size_in_words =
152 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2,
153 Representation::Integer32()));
154 builder.CheckIntegerEq(boilerplate_size, size_in_words);
155
156 HValue* size_in_bytes =
157 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
158 HInstruction* object =
159 AddInstruction(new(zone) HAllocate(context(),
160 size_in_bytes,
161 HType::JSObject(),
162 HAllocate::CAN_ALLOCATE_IN_NEW_SPACE));
163
164 for (int i = 0; i < size; i += kPointerSize) {
165 HInstruction* value =
166 AddInstruction(new(zone) HLoadNamedField(boilerplate, true, i));
167 AddInstruction(new(zone) HStoreNamedField(object,
168 factory->empty_symbol(),
169 value,
170 true, i));
171 AddSimulate(BailoutId::StubEntry());
172 }
173
174 builder.End();
175
176 HReturn* ret = new(zone) HReturn(object, context());
177 current_block()->Finish(ret);
178 }
179
180
181 Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
182 CodeStubGraphBuilder<FastCloneShallowObjectStub> builder(this);
183 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
184 return chunk->Codegen(Code::COMPILED_STUB);
185 }
186
187
188 template <>
135 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { 189 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
136 Zone* zone = this->zone(); 190 Zone* zone = this->zone();
137 191
138 HInstruction* load = BuildUncheckedMonomorphicElementAccess( 192 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
139 GetParameter(0), GetParameter(1), NULL, NULL, 193 GetParameter(0), GetParameter(1), NULL, NULL,
140 casted_stub()->is_js_array(), casted_stub()->elements_kind(), 194 casted_stub()->is_js_array(), casted_stub()->elements_kind(),
141 false, Representation::Tagged()); 195 false, Representation::Tagged());
142 AddInstruction(load); 196 AddInstruction(load);
143 197
144 HReturn* ret = new(zone) HReturn(load, context()); 198 HReturn* ret = new(zone) HReturn(load, context());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 298
245 299
246 Handle<Code> TransitionElementsKindStub::GenerateCode() { 300 Handle<Code> TransitionElementsKindStub::GenerateCode() {
247 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this); 301 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this);
248 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 302 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
249 return chunk->Codegen(Code::COMPILED_STUB); 303 return chunk->Codegen(Code::COMPILED_STUB);
250 } 304 }
251 305
252 306
253 } } // namespace v8::internal 307 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698