OLD | NEW |
---|---|
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 Loading... | |
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, | |
167 true, i)); | |
Jakob Kummerow
2013/02/08 12:45:49
nit: fits on last line
Michael Starzinger
2013/02/11 12:13:22
Done.
| |
168 AddInstruction(new(zone) HStoreNamedField(object, | |
169 factory->empty_symbol(), | |
170 value, | |
171 true, i)); | |
172 AddSimulate(BailoutId::StubEntry()); | |
173 } | |
174 | |
175 builder.End(); | |
176 | |
177 HReturn* ret = new(zone) HReturn(object, context()); | |
178 current_block()->Finish(ret); | |
179 } | |
180 | |
181 | |
182 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | |
183 CodeStubGraphBuilder<FastCloneShallowObjectStub> builder(this); | |
184 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | |
185 return chunk->Codegen(Code::COMPILED_STUB); | |
186 } | |
187 | |
188 | |
189 template <> | |
135 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { | 190 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
136 Zone* zone = this->zone(); | 191 Zone* zone = this->zone(); |
137 | 192 |
138 HInstruction* load = BuildUncheckedMonomorphicElementAccess( | 193 HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
139 GetParameter(0), GetParameter(1), NULL, NULL, | 194 GetParameter(0), GetParameter(1), NULL, NULL, |
140 casted_stub()->is_js_array(), casted_stub()->elements_kind(), | 195 casted_stub()->is_js_array(), casted_stub()->elements_kind(), |
141 false, Representation::Tagged()); | 196 false, Representation::Tagged()); |
142 AddInstruction(load); | 197 AddInstruction(load); |
143 | 198 |
144 HReturn* ret = new(zone) HReturn(load, context()); | 199 HReturn* ret = new(zone) HReturn(load, context()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 299 |
245 | 300 |
246 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 301 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
247 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this); | 302 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this); |
248 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 303 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
249 return chunk->Codegen(Code::COMPILED_STUB); | 304 return chunk->Codegen(Code::COMPILED_STUB); |
250 } | 305 } |
251 | 306 |
252 | 307 |
253 } } // namespace v8::internal | 308 } } // namespace v8::internal |
OLD | NEW |