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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 196 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
197 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 197 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
198 int length = casted_stub()->length(); | 198 int length = casted_stub()->length(); |
199 | 199 |
200 HInstruction* boilerplate = | 200 HInstruction* boilerplate = |
201 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 201 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
202 GetParameter(1), | 202 GetParameter(1), |
203 NULL, | 203 NULL, |
204 FAST_ELEMENTS)); | 204 FAST_ELEMENTS)); |
205 | 205 |
206 CheckBuilder builder(this, BailoutId::StubEntry()); | 206 CheckBuilder builder(this); |
207 builder.CheckNotUndefined(boilerplate); | 207 builder.CheckNotUndefined(boilerplate); |
208 | 208 |
209 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 209 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
210 HValue* elements = | 210 HValue* elements = |
211 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); | 211 AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); |
212 | 212 |
213 IfBuilder if_fixed_cow(this, BailoutId::StubEntry()); | 213 IfBuilder if_fixed_cow(this); |
214 if_fixed_cow.BeginIfMapEquals(elements, factory->fixed_cow_array_map()); | 214 if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map()); |
| 215 if_fixed_cow.Then(); |
215 environment()->Push(BuildCloneShallowArray(context(), | 216 environment()->Push(BuildCloneShallowArray(context(), |
216 boilerplate, | 217 boilerplate, |
217 alloc_site_mode, | 218 alloc_site_mode, |
218 FAST_ELEMENTS, | 219 FAST_ELEMENTS, |
219 0/*copy-on-write*/)); | 220 0/*copy-on-write*/)); |
220 if_fixed_cow.BeginElse(); | 221 if_fixed_cow.Else(); |
221 | 222 |
222 IfBuilder if_fixed(this, BailoutId::StubEntry()); | 223 IfBuilder if_fixed(this); |
223 if_fixed.BeginIfMapEquals(elements, factory->fixed_array_map()); | 224 if_fixed.IfCompareMap(elements, factory->fixed_array_map()); |
| 225 if_fixed.Then(); |
224 environment()->Push(BuildCloneShallowArray(context(), | 226 environment()->Push(BuildCloneShallowArray(context(), |
225 boilerplate, | 227 boilerplate, |
226 alloc_site_mode, | 228 alloc_site_mode, |
227 FAST_ELEMENTS, | 229 FAST_ELEMENTS, |
228 length)); | 230 length)); |
229 if_fixed.BeginElse(); | 231 if_fixed.Else(); |
230 | |
231 environment()->Push(BuildCloneShallowArray(context(), | 232 environment()->Push(BuildCloneShallowArray(context(), |
232 boilerplate, | 233 boilerplate, |
233 alloc_site_mode, | 234 alloc_site_mode, |
234 FAST_DOUBLE_ELEMENTS, | 235 FAST_DOUBLE_ELEMENTS, |
235 length)); | 236 length)); |
236 } else { | 237 } else { |
237 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 238 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
238 environment()->Push(BuildCloneShallowArray(context(), | 239 environment()->Push(BuildCloneShallowArray(context(), |
239 boilerplate, | 240 boilerplate, |
240 alloc_site_mode, | 241 alloc_site_mode, |
(...skipping 16 matching lines...) Expand all Loading... |
257 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 258 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
258 Zone* zone = this->zone(); | 259 Zone* zone = this->zone(); |
259 Factory* factory = isolate()->factory(); | 260 Factory* factory = isolate()->factory(); |
260 | 261 |
261 HInstruction* boilerplate = | 262 HInstruction* boilerplate = |
262 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 263 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
263 GetParameter(1), | 264 GetParameter(1), |
264 NULL, | 265 NULL, |
265 FAST_ELEMENTS)); | 266 FAST_ELEMENTS)); |
266 | 267 |
267 CheckBuilder builder(this, BailoutId::StubEntry()); | 268 CheckBuilder builder(this); |
268 builder.CheckNotUndefined(boilerplate); | 269 builder.CheckNotUndefined(boilerplate); |
269 | 270 |
270 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; | 271 int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; |
271 HValue* boilerplate_size = | 272 HValue* boilerplate_size = |
272 AddInstruction(new(zone) HInstanceSize(boilerplate)); | 273 AddInstruction(new(zone) HInstanceSize(boilerplate)); |
273 HValue* size_in_words = | 274 HValue* size_in_words = |
274 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, | 275 AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2, |
275 Representation::Integer32())); | 276 Representation::Integer32())); |
276 builder.CheckIntegerEq(boilerplate_size, size_in_words); | 277 builder.CheckIntegerEq(boilerplate_size, size_in_words); |
277 | 278 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 350 |
350 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); | 351 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); |
351 | 352 |
352 HInstruction* array_length = | 353 HInstruction* array_length = |
353 AddInstruction(HLoadNamedField::NewArrayLength( | 354 AddInstruction(HLoadNamedField::NewArrayLength( |
354 zone, js_array, js_array, HType::Smi())); | 355 zone, js_array, js_array, HType::Smi())); |
355 | 356 |
356 ElementsKind to_kind = casted_stub()->to_kind(); | 357 ElementsKind to_kind = casted_stub()->to_kind(); |
357 BuildNewSpaceArrayCheck(array_length, to_kind); | 358 BuildNewSpaceArrayCheck(array_length, to_kind); |
358 | 359 |
359 IfBuilder if_builder(this, BailoutId::StubEntry()); | 360 IfBuilder if_builder(this); |
360 | 361 |
361 if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ); | 362 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); |
| 363 if_builder.Then(); |
362 | 364 |
363 // Nothing to do, just change the map. | 365 // Nothing to do, just change the map. |
364 | 366 |
365 if_builder.BeginElse(); | 367 if_builder.Else(); |
366 | 368 |
367 HInstruction* elements = | 369 HInstruction* elements = |
368 AddInstruction(new(zone) HLoadElements(js_array, js_array)); | 370 AddInstruction(new(zone) HLoadElements(js_array, js_array)); |
369 | 371 |
370 HInstruction* elements_length = | 372 HInstruction* elements_length = |
371 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 373 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
372 | 374 |
373 HValue* new_elements = | 375 HValue* new_elements = |
374 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); | 376 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); |
375 | 377 |
376 BuildCopyElements(context(), elements, | 378 BuildCopyElements(context(), elements, |
377 casted_stub()->from_kind(), new_elements, | 379 casted_stub()->from_kind(), new_elements, |
378 to_kind, array_length, elements_length, | 380 to_kind, array_length, elements_length); |
379 BailoutId::StubEntry()); | |
380 | 381 |
381 Factory* factory = isolate()->factory(); | 382 Factory* factory = isolate()->factory(); |
382 | 383 |
383 AddInstruction(new(zone) HStoreNamedField(js_array, | 384 AddInstruction(new(zone) HStoreNamedField(js_array, |
384 factory->elements_field_string(), | 385 factory->elements_field_string(), |
385 new_elements, true, | 386 new_elements, true, |
386 JSArray::kElementsOffset)); | 387 JSArray::kElementsOffset)); |
387 | 388 |
388 if_builder.End(); | 389 if_builder.End(); |
389 | 390 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 current_block()->MarkAsDeoptimizing(); | 435 current_block()->MarkAsDeoptimizing(); |
435 return GetParameter(0); | 436 return GetParameter(0); |
436 } | 437 } |
437 | 438 |
438 | 439 |
439 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 440 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
440 return DoGenerateCode(this); | 441 return DoGenerateCode(this); |
441 } | 442 } |
442 | 443 |
443 } } // namespace v8::internal | 444 } } // namespace v8::internal |
OLD | NEW |