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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 template <class Stub> | 183 template <class Stub> |
184 static Handle<Code> DoGenerateCode(Stub* stub) { | 184 static Handle<Code> DoGenerateCode(Stub* stub) { |
185 CodeStubGraphBuilder<Stub> builder(stub); | 185 CodeStubGraphBuilder<Stub> builder(stub); |
186 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 186 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
187 return chunk->Codegen(Code::COMPILED_STUB); | 187 return chunk->Codegen(Code::COMPILED_STUB); |
188 } | 188 } |
189 | 189 |
190 | 190 |
191 template <> | 191 template <> |
| 192 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
| 193 Zone* zone = this->zone(); |
| 194 Factory* factory = isolate()->factory(); |
| 195 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
| 196 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
| 197 int length = casted_stub()->length(); |
| 198 |
| 199 HInstruction* boilerplate = |
| 200 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
| 201 GetParameter(1), |
| 202 NULL, |
| 203 FAST_ELEMENTS)); |
| 204 |
| 205 CheckBuilder builder(this); |
| 206 builder.CheckNotUndefined(boilerplate); |
| 207 |
| 208 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
| 209 HValue* elements = |
| 210 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); |
| 211 |
| 212 IfBuilder if_fixed_cow(this); |
| 213 if_fixed_cow.BeginIfMapEquals(elements, factory->fixed_cow_array_map()); |
| 214 environment()->Push(BuildCloneShallowArray(context(), |
| 215 boilerplate, |
| 216 alloc_site_mode, |
| 217 FAST_ELEMENTS, |
| 218 BailoutId::StubEntry(), |
| 219 0/*copy-on-write*/)); |
| 220 if_fixed_cow.BeginElse(); |
| 221 |
| 222 IfBuilder if_fixed(this); |
| 223 if_fixed.BeginIfMapEquals(elements, factory->fixed_array_map()); |
| 224 environment()->Push(BuildCloneShallowArray(context(), |
| 225 boilerplate, |
| 226 alloc_site_mode, |
| 227 FAST_ELEMENTS, |
| 228 BailoutId::StubEntry(), |
| 229 length)); |
| 230 if_fixed.BeginElse(); |
| 231 |
| 232 environment()->Push(BuildCloneShallowArray(context(), |
| 233 boilerplate, |
| 234 alloc_site_mode, |
| 235 FAST_DOUBLE_ELEMENTS, |
| 236 BailoutId::StubEntry(), |
| 237 length)); |
| 238 } else { |
| 239 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
| 240 environment()->Push(BuildCloneShallowArray(context(), |
| 241 boilerplate, |
| 242 alloc_site_mode, |
| 243 elements_kind, |
| 244 BailoutId::StubEntry(), |
| 245 length)); |
| 246 } |
| 247 |
| 248 return environment()->Pop(); |
| 249 } |
| 250 |
| 251 |
| 252 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
| 253 CodeStubGraphBuilder<FastCloneShallowArrayStub> builder(this); |
| 254 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
| 255 return chunk->Codegen(Code::COMPILED_STUB); |
| 256 } |
| 257 |
| 258 |
| 259 template <> |
192 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 260 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
193 Zone* zone = this->zone(); | 261 Zone* zone = this->zone(); |
194 Factory* factory = isolate()->factory(); | 262 Factory* factory = isolate()->factory(); |
195 | 263 |
196 HInstruction* boilerplate = | 264 HInstruction* boilerplate = |
197 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 265 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
198 GetParameter(1), | 266 GetParameter(1), |
199 NULL, | 267 NULL, |
200 FAST_ELEMENTS)); | 268 FAST_ELEMENTS)); |
201 | 269 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 current_block()->MarkAsDeoptimizing(); | 440 current_block()->MarkAsDeoptimizing(); |
373 return GetParameter(0); | 441 return GetParameter(0); |
374 } | 442 } |
375 | 443 |
376 | 444 |
377 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 445 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
378 return DoGenerateCode(this); | 446 return DoGenerateCode(this); |
379 } | 447 } |
380 | 448 |
381 } } // namespace v8::internal | 449 } } // namespace v8::internal |
OLD | NEW |