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

Side by Side Diff: src/bootstrapper.cc

Issue 259773009: Convert array.length to API-style accessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
« no previous file with comments | « src/accessors.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // is 1. 856 // is 1.
857 array_function->shared()->set_length(1); 857 array_function->shared()->set_length(1);
858 858
859 Handle<Map> initial_map(array_function->initial_map()); 859 Handle<Map> initial_map(array_function->initial_map());
860 860
861 // This assert protects an optimization in 861 // This assert protects an optimization in
862 // HGraphBuilder::JSArrayBuilder::EmitMapCode() 862 // HGraphBuilder::JSArrayBuilder::EmitMapCode()
863 ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind()); 863 ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind());
864 Map::EnsureDescriptorSlack(initial_map, 1); 864 Map::EnsureDescriptorSlack(initial_map, 1);
865 865
866 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
867 PropertyAttributes attribs = static_cast<PropertyAttributes>( 866 PropertyAttributes attribs = static_cast<PropertyAttributes>(
868 DONT_ENUM | DONT_DELETE); 867 DONT_ENUM | DONT_DELETE);
869 868
869 Handle<AccessorInfo> array_length =
870 Accessors::ArrayLengthInfo(isolate, attribs);
870 { // Add length. 871 { // Add length.
871 CallbacksDescriptor d(factory->length_string(), array_length, attribs); 872 CallbacksDescriptor d(
873 Handle<Name>(Name::cast(array_length->name())),
874 array_length, attribs);
872 array_function->initial_map()->AppendDescriptor(&d); 875 array_function->initial_map()->AppendDescriptor(&d);
873 } 876 }
874 877
875 // array_function is used internally. JS code creating array object should 878 // array_function is used internally. JS code creating array object should
876 // search for the 'Array' property on the global object and use that one 879 // search for the 'Array' property on the global object and use that one
877 // as the constructor. 'Array' property on a global object can be 880 // as the constructor. 'Array' property on a global object can be
878 // overwritten by JS code. 881 // overwritten by JS code.
879 native_context()->set_array_function(*array_function); 882 native_context()->set_array_function(*array_function);
880 883
881 // Cache the array maps, needed by ArrayConstructorStub 884 // Cache the array maps, needed by ArrayConstructorStub
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 array_function->shared()->DontAdaptArguments(); 1610 array_function->shared()->DontAdaptArguments();
1608 1611
1609 Handle<Map> original_map(array_function->initial_map()); 1612 Handle<Map> original_map(array_function->initial_map());
1610 Handle<Map> initial_map = Map::Copy(original_map); 1613 Handle<Map> initial_map = Map::Copy(original_map);
1611 initial_map->set_elements_kind(elements_kind); 1614 initial_map->set_elements_kind(elements_kind);
1612 array_function->set_initial_map(*initial_map); 1615 array_function->set_initial_map(*initial_map);
1613 1616
1614 // Make "length" magic on instances. 1617 // Make "length" magic on instances.
1615 Map::EnsureDescriptorSlack(initial_map, 1); 1618 Map::EnsureDescriptorSlack(initial_map, 1);
1616 1619
1617 Handle<Foreign> array_length(factory()->NewForeign(
1618 &Accessors::ArrayLength));
1619 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1620 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1620 DONT_ENUM | DONT_DELETE); 1621 DONT_ENUM | DONT_DELETE);
1621 1622
1623 Handle<AccessorInfo> array_length =
1624 Accessors::ArrayLengthInfo(isolate(), attribs);
1622 { // Add length. 1625 { // Add length.
1623 CallbacksDescriptor d( 1626 CallbacksDescriptor d(
1624 factory()->length_string(), array_length, attribs); 1627 Handle<Name>(Name::cast(array_length->name())), array_length, attribs);
1625 array_function->initial_map()->AppendDescriptor(&d); 1628 array_function->initial_map()->AppendDescriptor(&d);
1626 } 1629 }
1627 1630
1628 return array_function; 1631 return array_function;
1629 } 1632 }
1630 1633
1631 1634
1632 bool Genesis::InstallNatives() { 1635 bool Genesis::InstallNatives() {
1633 HandleScope scope(isolate()); 1636 HandleScope scope(isolate());
1634 1637
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 return from + sizeof(NestingCounterType); 2691 return from + sizeof(NestingCounterType);
2689 } 2692 }
2690 2693
2691 2694
2692 // Called when the top-level V8 mutex is destroyed. 2695 // Called when the top-level V8 mutex is destroyed.
2693 void Bootstrapper::FreeThreadResources() { 2696 void Bootstrapper::FreeThreadResources() {
2694 ASSERT(!IsActive()); 2697 ASSERT(!IsActive());
2695 } 2698 }
2696 2699
2697 } } // namespace v8::internal 2700 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698