OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 | 1553 |
1554 HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1()); | 1554 HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1()); |
1555 mask->ChangeRepresentation(Representation::Integer32()); | 1555 mask->ChangeRepresentation(Representation::Integer32()); |
1556 mask->ClearFlag(HValue::kCanOverflow); | 1556 mask->ClearFlag(HValue::kCanOverflow); |
1557 | 1557 |
1558 return BuildUncheckedDictionaryElementLoadHelper(elements, key, | 1558 return BuildUncheckedDictionaryElementLoadHelper(elements, key, |
1559 hash, mask, 0); | 1559 hash, mask, 0); |
1560 } | 1560 } |
1561 | 1561 |
1562 | 1562 |
| 1563 HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length, |
| 1564 HValue* index, |
| 1565 HValue* input) { |
| 1566 NoObservableSideEffectsScope scope(this); |
| 1567 |
| 1568 // Compute the size of the RegExpResult followed by FixedArray with length. |
| 1569 HValue* size = length; |
| 1570 size = AddUncasted<HShl>(size, Add<HConstant>(kPointerSizeLog2)); |
| 1571 size = AddUncasted<HAdd>(size, Add<HConstant>(static_cast<int32_t>( |
| 1572 JSRegExpResult::kSize + FixedArray::kHeaderSize))); |
| 1573 |
| 1574 // Make sure size does not exceeds max regular heap object size. |
| 1575 Add<HBoundsCheck>(size, Add<HConstant>(Page::kMaxRegularHeapObjectSize)); |
| 1576 |
| 1577 // Allocate the JSRegExpResult and the FixedArray in one step. |
| 1578 HValue* result = Add<HAllocate>( |
| 1579 size, HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); |
| 1580 |
| 1581 // Determine the elements FixedArray. |
| 1582 HValue* elements = Add<HInnerAllocatedObject>( |
| 1583 result, Add<HConstant>(JSRegExpResult::kSize)); |
| 1584 |
| 1585 // Initialize the JSRegExpResult header. |
| 1586 HValue* global_object = Add<HLoadNamedField>( |
| 1587 context(), static_cast<HValue*>(NULL), |
| 1588 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 1589 HValue* native_context = Add<HLoadNamedField>( |
| 1590 global_object, static_cast<HValue*>(NULL), |
| 1591 HObjectAccess::ForGlobalObjectNativeContext()); |
| 1592 AddStoreMapNoWriteBarrier(result, Add<HLoadNamedField>( |
| 1593 native_context, static_cast<HValue*>(NULL), |
| 1594 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); |
| 1595 Add<HStoreNamedField>( |
| 1596 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), |
| 1597 Add<HConstant>(isolate()->factory()->empty_fixed_array()), |
| 1598 INITIALIZING_STORE); |
| 1599 Add<HStoreNamedField>( |
| 1600 result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset), |
| 1601 elements, INITIALIZING_STORE); |
| 1602 Add<HStoreNamedField>( |
| 1603 result, HObjectAccess::ForJSArrayOffset(JSArray::kLengthOffset), |
| 1604 length, INITIALIZING_STORE); |
| 1605 |
| 1606 // Initialize the additional fields. |
| 1607 Add<HStoreNamedField>( |
| 1608 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kIndexOffset), |
| 1609 index, INITIALIZING_STORE); |
| 1610 Add<HStoreNamedField>( |
| 1611 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kInputOffset), |
| 1612 input, INITIALIZING_STORE); |
| 1613 |
| 1614 // Initialize the elements header. |
| 1615 AddStoreMapConstantNoWriteBarrier(elements, |
| 1616 isolate()->factory()->fixed_array_map()); |
| 1617 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), |
| 1618 length, INITIALIZING_STORE); |
| 1619 |
| 1620 // Initialize the elements contents with undefined. |
| 1621 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); |
| 1622 index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT); |
| 1623 { |
| 1624 Add<HStoreKeyed>(elements, index, graph()->GetConstantUndefined(), |
| 1625 FAST_ELEMENTS, INITIALIZING_STORE); |
| 1626 } |
| 1627 loop.EndBody(); |
| 1628 |
| 1629 return result; |
| 1630 } |
| 1631 |
| 1632 |
1563 HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { | 1633 HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { |
1564 NoObservableSideEffectsScope scope(this); | 1634 NoObservableSideEffectsScope scope(this); |
1565 | 1635 |
1566 // Convert constant numbers at compile time. | 1636 // Convert constant numbers at compile time. |
1567 if (object->IsConstant() && HConstant::cast(object)->HasNumberValue()) { | 1637 if (object->IsConstant() && HConstant::cast(object)->HasNumberValue()) { |
1568 Handle<Object> number = HConstant::cast(object)->handle(isolate()); | 1638 Handle<Object> number = HConstant::cast(object)->handle(isolate()); |
1569 Handle<String> result = isolate()->factory()->NumberToString(number); | 1639 Handle<String> result = isolate()->factory()->NumberToString(number); |
1570 return Add<HConstant>(result); | 1640 return Add<HConstant>(result); |
1571 } | 1641 } |
1572 | 1642 |
(...skipping 8840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10413 CHECK_ALIVE(VisitArgumentList(call->arguments())); | 10483 CHECK_ALIVE(VisitArgumentList(call->arguments())); |
10414 HCallStub* result = New<HCallStub>(CodeStub::RegExpExec, 4); | 10484 HCallStub* result = New<HCallStub>(CodeStub::RegExpExec, 4); |
10415 Drop(4); | 10485 Drop(4); |
10416 return ast_context()->ReturnInstruction(result, call->id()); | 10486 return ast_context()->ReturnInstruction(result, call->id()); |
10417 } | 10487 } |
10418 | 10488 |
10419 | 10489 |
10420 // Construct a RegExp exec result with two in-object properties. | 10490 // Construct a RegExp exec result with two in-object properties. |
10421 void HOptimizedGraphBuilder::GenerateRegExpConstructResult(CallRuntime* call) { | 10491 void HOptimizedGraphBuilder::GenerateRegExpConstructResult(CallRuntime* call) { |
10422 ASSERT_EQ(3, call->arguments()->length()); | 10492 ASSERT_EQ(3, call->arguments()->length()); |
10423 CHECK_ALIVE(VisitArgumentList(call->arguments())); | 10493 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
10424 HCallStub* result = New<HCallStub>(CodeStub::RegExpConstructResult, 3); | 10494 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
10425 Drop(3); | 10495 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); |
10426 return ast_context()->ReturnInstruction(result, call->id()); | 10496 HValue* input = Pop(); |
| 10497 HValue* index = Pop(); |
| 10498 HValue* length = Pop(); |
| 10499 HValue* result = BuildRegExpConstructResult(length, index, input); |
| 10500 return ast_context()->ReturnValue(result); |
10427 } | 10501 } |
10428 | 10502 |
10429 | 10503 |
10430 // Support for fast native caches. | 10504 // Support for fast native caches. |
10431 void HOptimizedGraphBuilder::GenerateGetFromCache(CallRuntime* call) { | 10505 void HOptimizedGraphBuilder::GenerateGetFromCache(CallRuntime* call) { |
10432 return Bailout(kInlinedRuntimeFunctionGetFromCache); | 10506 return Bailout(kInlinedRuntimeFunctionGetFromCache); |
10433 } | 10507 } |
10434 | 10508 |
10435 | 10509 |
10436 // Fast support for number to string. | 10510 // Fast support for number to string. |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11167 if (ShouldProduceTraceOutput()) { | 11241 if (ShouldProduceTraceOutput()) { |
11168 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11242 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11169 } | 11243 } |
11170 | 11244 |
11171 #ifdef DEBUG | 11245 #ifdef DEBUG |
11172 graph_->Verify(false); // No full verify. | 11246 graph_->Verify(false); // No full verify. |
11173 #endif | 11247 #endif |
11174 } | 11248 } |
11175 | 11249 |
11176 } } // namespace v8::internal | 11250 } } // namespace v8::internal |
OLD | NEW |