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

Side by Side Diff: src/hydrogen.cc

Issue 14576005: Adapt hydrogen-based Array constructor to also support InternalArray and function call (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Refactoring and restored flag for now Created 7 years, 7 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
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 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 HInstruction* array_function = AddInstruction(new(zone()) 1885 HInstruction* array_function = AddInstruction(new(zone())
1886 HLoadNamedField(native_context, true, Representation::Tagged(), offset)); 1886 HLoadNamedField(native_context, true, Representation::Tagged(), offset));
1887 return array_function; 1887 return array_function;
1888 } 1888 }
1889 1889
1890 1890
1891 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, 1891 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
1892 ElementsKind kind, 1892 ElementsKind kind,
1893 HValue* allocation_site_payload, 1893 HValue* allocation_site_payload,
1894 AllocationSiteMode mode) : 1894 AllocationSiteMode mode) :
1895 builder_(builder), 1895 builder_(builder),
Michael Starzinger 2013/05/23 09:16:49 nit: Indentation is off.
mvstanton 2013/05/23 14:46:05 Done.
1896 kind_(kind), 1896 kind_(kind),
1897 allocation_site_payload_(allocation_site_payload) { 1897 allocation_site_payload_(allocation_site_payload),
1898 constructor_function_(NULL) {
1898 if (mode == DONT_TRACK_ALLOCATION_SITE) { 1899 if (mode == DONT_TRACK_ALLOCATION_SITE) {
1899 mode_ = mode; 1900 mode_ = mode;
1900 } else { 1901 } else {
1901 mode_ = AllocationSiteInfo::GetMode(kind); 1902 mode_ = AllocationSiteInfo::GetMode(kind);
1902 } 1903 }
1903 } 1904 }
1904 1905
1905 1906
1907 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
1908 ElementsKind kind,
1909 HValue* constructor_function) :
1910 builder_(builder),
Michael Starzinger 2013/05/23 09:16:49 nit: Indentation is off.
mvstanton 2013/05/23 14:46:05 Done.
1911 kind_(kind),
1912 mode_(DONT_TRACK_ALLOCATION_SITE),
1913 allocation_site_payload_(NULL),
1914 constructor_function_(constructor_function) {
1915 }
1916
1917
1906 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { 1918 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) {
1907 HInstruction* native_context = builder()->BuildGetNativeContext(context); 1919 HInstruction* native_context = builder()->BuildGetNativeContext(context);
1908 int offset = Context::kHeaderSize + 1920 int offset = Context::kHeaderSize +
1909 kPointerSize * Context::JS_ARRAY_MAPS_INDEX; 1921 kPointerSize * Context::JS_ARRAY_MAPS_INDEX;
1910 HInstruction* map_array = AddInstruction(new(zone()) 1922 HInstruction* map_array = AddInstruction(new(zone())
1911 HLoadNamedField(native_context, true, Representation::Tagged(), offset)); 1923 HLoadNamedField(native_context, true, Representation::Tagged(), offset));
1912 offset = kind_ * kPointerSize + FixedArrayBase::kHeaderSize; 1924 offset = kind_ * kPointerSize + FixedArrayBase::kHeaderSize;
1913 return AddInstruction(new(zone()) HLoadNamedField( 1925 return AddInstruction(new(zone()) HLoadNamedField(
1914 map_array, true, Representation::Tagged(), offset)); 1926 map_array, true, Representation::Tagged(), offset));
1915 } 1927 }
1916 1928
1917 1929
1930 HValue* HGraphBuilder::JSArrayBuilder::InternalEmitMapCode() {
1931 // Find the map near the constructor function
1932 HValue* initial_map = AddInstruction(new(zone())
1933 HLoadNamedField(constructor_function_, true, Representation::Tagged(),
1934 JSFunction::kPrototypeOrInitialMapOffset));
1935 return initial_map;
1936 }
1937
1938
1918 HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize( 1939 HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize(
1919 HValue* length_node) { 1940 HValue* length_node) {
1920 HValue* context = builder()->environment()->LookupContext(); 1941 HValue* context = builder()->environment()->LookupContext();
1921 ASSERT(length_node != NULL); 1942 ASSERT(length_node != NULL);
1922 1943
1923 int base_size = JSArray::kSize; 1944 int base_size = JSArray::kSize;
1924 if (mode_ == TRACK_ALLOCATION_SITE) { 1945 if (mode_ == TRACK_ALLOCATION_SITE) {
1925 base_size += AllocationSiteInfo::kSize; 1946 base_size += AllocationSiteInfo::kSize;
1926 } 1947 }
1927 1948
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 bool fill_with_hole) { 2015 bool fill_with_hole) {
1995 HValue* context = builder()->environment()->LookupContext(); 2016 HValue* context = builder()->environment()->LookupContext();
1996 2017
1997 // Allocate (dealing with failure appropriately) 2018 // Allocate (dealing with failure appropriately)
1998 HAllocate::Flags flags = HAllocate::DefaultFlags(kind_); 2019 HAllocate::Flags flags = HAllocate::DefaultFlags(kind_);
1999 HAllocate* new_object = new(zone()) HAllocate(context, size_in_bytes, 2020 HAllocate* new_object = new(zone()) HAllocate(context, size_in_bytes,
2000 HType::JSArray(), flags); 2021 HType::JSArray(), flags);
2001 AddInstruction(new_object); 2022 AddInstruction(new_object);
2002 2023
2003 // Fill in the fields: map, properties, length 2024 // Fill in the fields: map, properties, length
2004 HValue* map = EmitMapCode(context); 2025 HValue* map;
2026 if (constructor_function_ != NULL) {
2027 map = InternalEmitMapCode();
2028 } else {
2029 map = EmitMapCode(context);
2030 }
2005 elements_location_ = builder()->BuildJSArrayHeader(new_object, 2031 elements_location_ = builder()->BuildJSArrayHeader(new_object,
2006 map, 2032 map,
2007 mode_, 2033 mode_,
2008 allocation_site_payload_, 2034 allocation_site_payload_,
2009 length_field); 2035 length_field);
2010 2036
2011 // Initialize the elements 2037 // Initialize the elements
2012 builder()->BuildInitializeElements(elements_location_, kind_, capacity); 2038 builder()->BuildInitializeElements(elements_location_, kind_, capacity);
2013 2039
2014 if (fill_with_hole) { 2040 if (fill_with_hole) {
(...skipping 10444 matching lines...) Expand 10 before | Expand all | Expand 10 after
12459 } 12485 }
12460 } 12486 }
12461 12487
12462 #ifdef DEBUG 12488 #ifdef DEBUG
12463 if (graph_ != NULL) graph_->Verify(false); // No full verify. 12489 if (graph_ != NULL) graph_->Verify(false); // No full verify.
12464 if (allocator_ != NULL) allocator_->Verify(); 12490 if (allocator_ != NULL) allocator_->Verify();
12465 #endif 12491 #endif
12466 } 12492 }
12467 12493
12468 } } // namespace v8::internal 12494 } } // namespace v8::internal
OLDNEW
« src/hydrogen.h ('K') | « src/hydrogen.h ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698