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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 static void GenerateFastCloneShallowArrayCommon( | 322 static void GenerateFastCloneShallowArrayCommon( |
323 MacroAssembler* masm, | 323 MacroAssembler* masm, |
324 int length, | 324 int length, |
325 FastCloneShallowArrayStub::Mode mode, | 325 FastCloneShallowArrayStub::Mode mode, |
326 AllocationSiteInfoMode allocation_site_info_mode, | 326 AllocationSiteInfoMode allocation_site_info_mode, |
327 Label* fail) { | 327 Label* fail) { |
328 // Registers on entry: | 328 // Registers on entry: |
329 // | 329 // |
330 // ecx: boilerplate literal array. | 330 // ecx: boilerplate literal array. |
331 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); | 331 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); |
332 bool tracking_on = allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO; | |
332 | 333 |
333 // All sizes here are multiples of kPointerSize. | 334 // All sizes here are multiples of kPointerSize. |
334 int elements_size = 0; | 335 int elements_size = 0; |
335 if (length > 0) { | 336 if (length > 0) { |
336 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 337 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
337 ? FixedDoubleArray::SizeFor(length) | 338 ? FixedDoubleArray::SizeFor(length) |
338 : FixedArray::SizeFor(length); | 339 : FixedArray::SizeFor(length); |
339 } | 340 } |
340 int size = JSArray::kSize; | 341 int size = JSArray::kSize; |
341 int allocation_info_start = size; | 342 int allocation_info_start = size; |
342 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 343 size += tracking_on ? AllocationSiteInfo::kSize + elements_size |
Toon Verwaest
2013/01/16 10:53:42
I prefer the original formatting for this piece of
mvstanton
2013/01/16 13:01:56
Done.
| |
343 size += AllocationSiteInfo::kSize; | 344 : elements_size; |
344 } | |
345 size += elements_size; | |
346 | 345 |
347 // Allocate both the JS array and the elements array in one big | 346 // Allocate both the JS array and the elements array in one big |
348 // allocation. This avoids multiple limit checks. | 347 // allocation. This avoids multiple limit checks. |
349 AllocationFlags flags = TAG_OBJECT; | 348 AllocationFlags flags = TAG_OBJECT; |
350 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { | 349 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { |
351 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); | 350 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); |
352 } | 351 } |
353 __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags); | 352 __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags); |
354 | 353 |
355 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 354 if (tracking_on) { |
356 __ mov(FieldOperand(eax, allocation_info_start), | 355 __ mov(FieldOperand(eax, allocation_info_start), |
357 Immediate(Handle<Map>(masm->isolate()->heap()-> | 356 Immediate(Handle<Map>(masm->isolate()->heap()-> |
358 allocation_site_info_map()))); | 357 allocation_site_info_map()))); |
359 __ mov(FieldOperand(eax, allocation_info_start + kPointerSize), ecx); | 358 __ mov(FieldOperand(eax, allocation_info_start + kPointerSize), ecx); |
360 } | 359 } |
361 | 360 |
362 // Copy the JS array part. | 361 // Copy the JS array part. |
363 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 362 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
364 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 363 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
365 __ mov(ebx, FieldOperand(ecx, i)); | 364 __ mov(ebx, FieldOperand(ecx, i)); |
366 __ mov(FieldOperand(eax, i), ebx); | 365 __ mov(FieldOperand(eax, i), ebx); |
367 } | 366 } |
368 } | 367 } |
369 | 368 |
370 if (length > 0) { | 369 if (length > 0) { |
371 // Get hold of the elements array of the boilerplate and setup the | 370 // Get hold of the elements array of the boilerplate and setup the |
372 // elements pointer in the resulting object. | 371 // elements pointer in the resulting object. |
373 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 372 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
374 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 373 if (tracking_on) { |
375 __ lea(edx, Operand(eax, JSArray::kSize + AllocationSiteInfo::kSize)); | 374 __ lea(edx, Operand(eax, JSArray::kSize + AllocationSiteInfo::kSize)); |
376 } else { | 375 } else { |
377 __ lea(edx, Operand(eax, JSArray::kSize)); | 376 __ lea(edx, Operand(eax, JSArray::kSize)); |
378 } | 377 } |
379 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); | 378 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); |
380 | 379 |
381 // Copy the elements array. | 380 // Copy the elements array. |
382 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) { | 381 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) { |
383 for (int i = 0; i < elements_size; i += kPointerSize) { | 382 for (int i = 0; i < elements_size; i += kPointerSize) { |
384 __ mov(ebx, FieldOperand(ecx, i)); | 383 __ mov(ebx, FieldOperand(ecx, i)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 STATIC_ASSERT(kSmiTag == 0); | 417 STATIC_ASSERT(kSmiTag == 0); |
419 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, | 418 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, |
420 FixedArray::kHeaderSize)); | 419 FixedArray::kHeaderSize)); |
421 Factory* factory = masm->isolate()->factory(); | 420 Factory* factory = masm->isolate()->factory(); |
422 __ cmp(ecx, factory->undefined_value()); | 421 __ cmp(ecx, factory->undefined_value()); |
423 Label slow_case; | 422 Label slow_case; |
424 __ j(equal, &slow_case); | 423 __ j(equal, &slow_case); |
425 | 424 |
426 FastCloneShallowArrayStub::Mode mode = mode_; | 425 FastCloneShallowArrayStub::Mode mode = mode_; |
427 // ecx is boilerplate object. | 426 // ecx is boilerplate object. |
428 AllocationSiteInfoMode allocation_site_info_mode = | |
429 DONT_TRACK_ALLOCATION_SITE_INFO; | |
430 if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO) { | |
431 mode = CLONE_ANY_ELEMENTS; | |
432 allocation_site_info_mode = TRACK_ALLOCATION_SITE_INFO; | |
433 } | |
434 | |
435 if (mode == CLONE_ANY_ELEMENTS) { | 427 if (mode == CLONE_ANY_ELEMENTS) { |
436 Label double_elements, check_fast_elements; | 428 Label double_elements, check_fast_elements; |
437 __ mov(ebx, FieldOperand(ecx, JSArray::kElementsOffset)); | 429 __ mov(ebx, FieldOperand(ecx, JSArray::kElementsOffset)); |
438 __ CheckMap(ebx, factory->fixed_cow_array_map(), | 430 __ CheckMap(ebx, factory->fixed_cow_array_map(), |
439 &check_fast_elements, DONT_DO_SMI_CHECK); | 431 &check_fast_elements, DONT_DO_SMI_CHECK); |
440 GenerateFastCloneShallowArrayCommon(masm, 0, | 432 GenerateFastCloneShallowArrayCommon(masm, 0, COPY_ON_WRITE_ELEMENTS, |
441 COPY_ON_WRITE_ELEMENTS, | 433 allocation_site_info_mode_, |
442 allocation_site_info_mode, | |
443 &slow_case); | 434 &slow_case); |
444 __ ret(3 * kPointerSize); | 435 __ ret(3 * kPointerSize); |
445 | 436 |
446 __ bind(&check_fast_elements); | 437 __ bind(&check_fast_elements); |
447 __ CheckMap(ebx, factory->fixed_array_map(), | 438 __ CheckMap(ebx, factory->fixed_array_map(), |
448 &double_elements, DONT_DO_SMI_CHECK); | 439 &double_elements, DONT_DO_SMI_CHECK); |
449 GenerateFastCloneShallowArrayCommon(masm, length_, | 440 GenerateFastCloneShallowArrayCommon(masm, length_, CLONE_ELEMENTS, |
450 CLONE_ELEMENTS, | 441 allocation_site_info_mode_, |
451 allocation_site_info_mode, | |
452 &slow_case); | 442 &slow_case); |
453 __ ret(3 * kPointerSize); | 443 __ ret(3 * kPointerSize); |
454 | 444 |
455 __ bind(&double_elements); | 445 __ bind(&double_elements); |
456 mode = CLONE_DOUBLE_ELEMENTS; | 446 mode = CLONE_DOUBLE_ELEMENTS; |
457 // Fall through to generate the code to handle double elements. | 447 // Fall through to generate the code to handle double elements. |
458 } | 448 } |
459 | 449 |
460 if (FLAG_debug_code) { | 450 if (FLAG_debug_code) { |
461 const char* message; | 451 const char* message; |
(...skipping 10 matching lines...) Expand all Loading... | |
472 expected_map = factory->fixed_cow_array_map(); | 462 expected_map = factory->fixed_cow_array_map(); |
473 } | 463 } |
474 __ push(ecx); | 464 __ push(ecx); |
475 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 465 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
476 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); | 466 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); |
477 __ Assert(equal, message); | 467 __ Assert(equal, message); |
478 __ pop(ecx); | 468 __ pop(ecx); |
479 } | 469 } |
480 | 470 |
481 GenerateFastCloneShallowArrayCommon(masm, length_, mode, | 471 GenerateFastCloneShallowArrayCommon(masm, length_, mode, |
482 allocation_site_info_mode, &slow_case); | 472 allocation_site_info_mode_, |
473 &slow_case); | |
474 | |
483 // Return and remove the on-stack parameters. | 475 // Return and remove the on-stack parameters. |
484 __ ret(3 * kPointerSize); | 476 __ ret(3 * kPointerSize); |
485 | 477 |
486 __ bind(&slow_case); | 478 __ bind(&slow_case); |
487 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 479 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
488 } | 480 } |
489 | 481 |
490 | 482 |
491 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { | 483 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { |
492 // Stack layout on entry: | 484 // Stack layout on entry: |
(...skipping 7050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7543 // Restore ecx. | 7535 // Restore ecx. |
7544 __ pop(ecx); | 7536 __ pop(ecx); |
7545 __ ret(0); | 7537 __ ret(0); |
7546 } | 7538 } |
7547 | 7539 |
7548 #undef __ | 7540 #undef __ |
7549 | 7541 |
7550 } } // namespace v8::internal | 7542 } } // namespace v8::internal |
7551 | 7543 |
7552 #endif // V8_TARGET_ARCH_IA32 | 7544 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |