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

Side by Side Diff: src/hydrogen.cc

Issue 12521011: Compile FastCloneShallowArrayStub using Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 8 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
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 builder.EndBody(); 1455 builder.EndBody();
1456 1456
1457 if (!pre_fill_with_holes && length != capacity) { 1457 if (!pre_fill_with_holes && length != capacity) {
1458 // Fill unused capacity with the hole. 1458 // Fill unused capacity with the hole.
1459 BuildFillElementsWithHole(context, to_elements, to_elements_kind, 1459 BuildFillElementsWithHole(context, to_elements, to_elements_kind,
1460 key, capacity); 1460 key, capacity);
1461 } 1461 }
1462 } 1462 }
1463 1463
1464 1464
1465 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context,
1466 HValue* boilerplate,
1467 AllocationSiteMode mode,
1468 ElementsKind kind,
1469 BailoutId id,
1470 int length) {
1471 Zone* zone = this->zone();
1472 Factory* factory = isolate()->factory();
1473
1474 // All sizes here are multiples of kPointerSize.
1475 int size = JSArray::kSize;
1476 if (mode == TRACK_ALLOCATION_SITE) {
1477 size += AllocationSiteInfo::kSize;
1478 }
1479 int elems_offset = size;
1480 if (length > 0) {
1481 size += IsFastDoubleElementsKind(kind)
1482 ? FixedDoubleArray::SizeFor(length)
1483 : FixedArray::SizeFor(length);
1484 }
1485
1486 HAllocate::Flags allocate_flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
1487 if (IsFastDoubleElementsKind(kind)) {
1488 allocate_flags = static_cast<HAllocate::Flags>(
1489 allocate_flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
1490 }
1491
1492 // Allocate both the JS array and the elements array in one big
1493 // allocation. This avoids multiple limit checks.
1494 HValue* size_in_bytes =
1495 AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
1496 HInstruction* object =
1497 AddInstruction(new(zone) HAllocate(context,
1498 size_in_bytes,
1499 HType::JSObject(),
1500 allocate_flags));
1501
1502 // Copy the JS array part.
1503 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
1504 if ((i != JSArray::kElementsOffset) || (length == 0)) {
1505 HInstruction* value =
1506 AddInstruction(new(zone) HLoadNamedField(boilerplate, true, i));
1507 if (i != JSArray::kMapOffset) {
1508 AddInstruction(new(zone) HStoreNamedField(object,
1509 factory->empty_string(),
1510 value,
1511 true, i));
1512 AddSimulate(id);
1513 } else {
1514 BuildStoreMap(object, value, id);
1515 }
1516 }
1517 }
1518
1519 // Create an allocation site info if requested.
1520 if (mode == TRACK_ALLOCATION_SITE) {
1521 HValue* alloc_site =
1522 AddInstruction(new(zone) HInnerAllocatedObject(object, JSArray::kSize));
1523 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map());
1524 BuildStoreMap(alloc_site, alloc_site_map, id);
1525 int alloc_payload_offset = AllocationSiteInfo::kPayloadOffset;
1526 AddInstruction(new(zone) HStoreNamedField(alloc_site,
1527 factory->empty_string(),
1528 boilerplate,
1529 true, alloc_payload_offset));
1530 AddSimulate(id);
1531 }
1532
1533 if (length > 0) {
1534 // Get hold of the elements array of the boilerplate and setup the
1535 // elements pointer in the resulting object.
1536 HValue* boilerplate_elements =
1537 AddInstruction(new(zone) HLoadElements(boilerplate, NULL));
1538 HValue* object_elements =
1539 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset));
1540 AddInstruction(new(zone) HStoreNamedField(object,
1541 factory->elements_field_string(),
1542 object_elements,
1543 true, JSObject::kElementsOffset));
1544 AddSimulate(id);
1545
1546 // Copy the elements array header.
1547 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
1548 HInstruction* value =
1549 AddInstruction(new(zone) HLoadNamedField(boilerplate_elements,
1550 true, i));
1551 AddInstruction(new(zone) HStoreNamedField(object_elements,
1552 factory->empty_string(),
1553 value,
1554 true, i));
1555 AddSimulate(id);
1556 }
1557
1558 // Copy the elements array contents.
1559 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold
1560 // copying loops with constant length up to a given boundary and use this
1561 // helper here instead.
1562 for (int i = 0; i < length; i++) {
1563 HValue* key_constant =
1564 AddInstruction(new(zone) HConstant(i, Representation::Integer32()));
1565 HInstruction* value =
1566 AddInstruction(new(zone) HLoadKeyed(boilerplate_elements,
1567 key_constant,
1568 NULL,
1569 kind));
1570 AddInstruction(new(zone) HStoreKeyed(object_elements,
1571 key_constant,
1572 value,
1573 kind));
1574 AddSimulate(id);
1575 }
1576 }
1577
1578 return object;
1579 }
1580
1581
1465 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info, 1582 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info,
1466 TypeFeedbackOracle* oracle) 1583 TypeFeedbackOracle* oracle)
1467 : HGraphBuilder(info), 1584 : HGraphBuilder(info),
1468 function_state_(NULL), 1585 function_state_(NULL),
1469 initial_function_state_(this, info, oracle, NORMAL_RETURN), 1586 initial_function_state_(this, info, oracle, NORMAL_RETURN),
1470 ast_context_(NULL), 1587 ast_context_(NULL),
1471 break_scope_(NULL), 1588 break_scope_(NULL),
1472 inlined_count_(0), 1589 inlined_count_(0),
1473 globals_(10, info->zone()), 1590 globals_(10, info->zone()),
1474 inline_bailout_(false) { 1591 inline_bailout_(false) {
(...skipping 9811 matching lines...) Expand 10 before | Expand all | Expand 10 after
11286 } 11403 }
11287 } 11404 }
11288 11405
11289 #ifdef DEBUG 11406 #ifdef DEBUG
11290 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11407 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11291 if (allocator_ != NULL) allocator_->Verify(); 11408 if (allocator_ != NULL) allocator_->Verify();
11292 #endif 11409 #endif
11293 } 11410 }
11294 11411
11295 } } // namespace v8::internal 11412 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698