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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 | 1862 |
1863 // Allocate the ASCII string object. | 1863 // Allocate the ASCII string object. |
1864 Handle<Map> map = isolate()->factory()->ascii_string_map(); | 1864 Handle<Map> map = isolate()->factory()->ascii_string_map(); |
1865 HAllocate* string = Add<HAllocate>(size, HType::String(), | 1865 HAllocate* string = Add<HAllocate>(size, HType::String(), |
1866 pretenure_flag, ASCII_STRING_TYPE); | 1866 pretenure_flag, ASCII_STRING_TYPE); |
1867 string->set_known_initial_map(map); | 1867 string->set_known_initial_map(map); |
1868 | 1868 |
1869 // We can safely skip the write barrier for storing map here. | 1869 // We can safely skip the write barrier for storing map here. |
1870 AddStoreMapConstantNoWriteBarrier(string, map); | 1870 AddStoreMapConstantNoWriteBarrier(string, map); |
1871 | 1871 |
| 1872 // Length must be stored into the string before we copy characters to |
| 1873 // make debug verification code happy. |
| 1874 Add<HStoreNamedField>(string, HObjectAccess::ForStringLength(), |
| 1875 length); |
| 1876 |
1872 // Copy bytes from the left string. | 1877 // Copy bytes from the left string. |
1873 BuildCopySeqStringChars( | 1878 BuildCopySeqStringChars( |
1874 left, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, | 1879 left, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, |
1875 string, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, | 1880 string, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, |
1876 left_length); | 1881 left_length); |
1877 | 1882 |
1878 // Copy bytes from the right string. | 1883 // Copy bytes from the right string. |
1879 BuildCopySeqStringChars( | 1884 BuildCopySeqStringChars( |
1880 right, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, | 1885 right, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, |
1881 string, left_length, String::ONE_BYTE_ENCODING, | 1886 string, left_length, String::ONE_BYTE_ENCODING, |
(...skipping 11 matching lines...) Expand all Loading... |
1893 | 1898 |
1894 // Allocate the two-byte string object. | 1899 // Allocate the two-byte string object. |
1895 Handle<Map> map = isolate()->factory()->string_map(); | 1900 Handle<Map> map = isolate()->factory()->string_map(); |
1896 HAllocate* string = Add<HAllocate>(size, HType::String(), | 1901 HAllocate* string = Add<HAllocate>(size, HType::String(), |
1897 pretenure_flag, STRING_TYPE); | 1902 pretenure_flag, STRING_TYPE); |
1898 string->set_known_initial_map(map); | 1903 string->set_known_initial_map(map); |
1899 | 1904 |
1900 // We can safely skip the write barrier for storing map here. | 1905 // We can safely skip the write barrier for storing map here. |
1901 AddStoreMapConstantNoWriteBarrier(string, map); | 1906 AddStoreMapConstantNoWriteBarrier(string, map); |
1902 | 1907 |
| 1908 // Length must be stored into the string before we copy characters to |
| 1909 // make debug verification code happy. |
| 1910 Add<HStoreNamedField>(string, HObjectAccess::ForStringLength(), |
| 1911 length); |
| 1912 |
1903 // Copy bytes from the left string. | 1913 // Copy bytes from the left string. |
1904 BuildCopySeqStringChars( | 1914 BuildCopySeqStringChars( |
1905 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1915 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
1906 string, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1916 string, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
1907 left_length); | 1917 left_length); |
1908 | 1918 |
1909 // Copy bytes from the right string. | 1919 // Copy bytes from the right string. |
1910 BuildCopySeqStringChars( | 1920 BuildCopySeqStringChars( |
1911 right, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1921 right, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
1912 string, left_length, String::TWO_BYTE_ENCODING, | 1922 string, left_length, String::TWO_BYTE_ENCODING, |
1913 right_length); | 1923 right_length); |
1914 | 1924 |
1915 // Return the string. | 1925 // Return the string. |
1916 Push(string); | 1926 Push(string); |
1917 } | 1927 } |
1918 if_onebyte.End(); | 1928 if_onebyte.End(); |
1919 | 1929 |
1920 // Initialize the (common) string fields. | 1930 // Initialize the (common) string fields. |
1921 HValue* string = Pop(); | 1931 HValue* string = Pop(); |
1922 Add<HStoreNamedField>(string, HObjectAccess::ForStringHashField(), | 1932 Add<HStoreNamedField>(string, HObjectAccess::ForStringHashField(), |
1923 Add<HConstant>(String::kEmptyHashField)); | 1933 Add<HConstant>(String::kEmptyHashField)); |
1924 Add<HStoreNamedField>(string, HObjectAccess::ForStringLength(), | |
1925 length); | |
1926 Push(string); | 1934 Push(string); |
1927 } | 1935 } |
1928 if_sameencodingandsequential.JoinContinuation(&handled); | 1936 if_sameencodingandsequential.JoinContinuation(&handled); |
1929 } | 1937 } |
1930 if_createcons.JoinContinuation(&handled); | 1938 if_createcons.JoinContinuation(&handled); |
1931 } | 1939 } |
1932 if_nooverflow.JoinContinuation(&handled); | 1940 if_nooverflow.JoinContinuation(&handled); |
1933 | 1941 |
1934 // Check if the strings were concatenated successfully, otherwise fallback to | 1942 // Check if the strings were concatenated successfully, otherwise fallback to |
1935 // add the strings in the runtime. | 1943 // add the strings in the runtime. |
(...skipping 7772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9708 | 9716 |
9709 void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( | 9717 void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( |
9710 CallRuntime* call) { | 9718 CallRuntime* call) { |
9711 ASSERT(call->arguments()->length() == 3); | 9719 ASSERT(call->arguments()->length() == 3); |
9712 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9720 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
9713 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 9721 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
9714 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); | 9722 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); |
9715 HValue* value = Pop(); | 9723 HValue* value = Pop(); |
9716 HValue* index = Pop(); | 9724 HValue* index = Pop(); |
9717 HValue* string = Pop(); | 9725 HValue* string = Pop(); |
9718 HSeqStringSetChar* result = New<HSeqStringSetChar>( | 9726 Add<HSeqStringSetChar>(String::ONE_BYTE_ENCODING, string, |
9719 String::ONE_BYTE_ENCODING, string, index, value); | 9727 index, value); |
9720 return ast_context()->ReturnInstruction(result, call->id()); | 9728 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
| 9729 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
9721 } | 9730 } |
9722 | 9731 |
9723 | 9732 |
9724 void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( | 9733 void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( |
9725 CallRuntime* call) { | 9734 CallRuntime* call) { |
9726 ASSERT(call->arguments()->length() == 3); | 9735 ASSERT(call->arguments()->length() == 3); |
9727 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9736 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
9728 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 9737 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
9729 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); | 9738 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); |
9730 HValue* value = Pop(); | 9739 HValue* value = Pop(); |
9731 HValue* index = Pop(); | 9740 HValue* index = Pop(); |
9732 HValue* string = Pop(); | 9741 HValue* string = Pop(); |
9733 HSeqStringSetChar* result = New<HSeqStringSetChar>( | 9742 Add<HSeqStringSetChar>(String::TWO_BYTE_ENCODING, string, |
9734 String::TWO_BYTE_ENCODING, string, index, value); | 9743 index, value); |
9735 return ast_context()->ReturnInstruction(result, call->id()); | 9744 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
| 9745 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
9736 } | 9746 } |
9737 | 9747 |
9738 | 9748 |
9739 void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) { | 9749 void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) { |
9740 ASSERT(call->arguments()->length() == 2); | 9750 ASSERT(call->arguments()->length() == 2); |
9741 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9751 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
9742 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 9752 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
9743 HValue* value = Pop(); | 9753 HValue* value = Pop(); |
9744 HValue* object = Pop(); | 9754 HValue* object = Pop(); |
9745 // Check if object is a not a smi. | 9755 // Check if object is a not a smi. |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10623 if (ShouldProduceTraceOutput()) { | 10633 if (ShouldProduceTraceOutput()) { |
10624 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10634 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10625 } | 10635 } |
10626 | 10636 |
10627 #ifdef DEBUG | 10637 #ifdef DEBUG |
10628 graph_->Verify(false); // No full verify. | 10638 graph_->Verify(false); // No full verify. |
10629 #endif | 10639 #endif |
10630 } | 10640 } |
10631 | 10641 |
10632 } } // namespace v8::internal | 10642 } } // namespace v8::internal |
OLD | NEW |