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

Side by Side Diff: src/elements.h

Issue 9638014: Implement efficient element copying in ElementsAccessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Undo inlining Created 8 years, 9 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/builtins.cc ('k') | src/elements.cc » ('j') | src/elements.cc » ('J')
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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_ELEMENTS_H_ 28 #ifndef V8_ELEMENTS_H_
29 #define V8_ELEMENTS_H_ 29 #define V8_ELEMENTS_H_
30 30
31 #include "objects.h" 31 #include "objects.h"
32 #include "heap.h"
33 #include "isolate.h"
32 34
33 namespace v8 { 35 namespace v8 {
34 namespace internal { 36 namespace internal {
35 37
36 // Abstract base class for handles that can operate on objects with differing 38 // Abstract base class for handles that can operate on objects with differing
37 // ElementsKinds. 39 // ElementsKinds.
38 class ElementsAccessor { 40 class ElementsAccessor {
39 public: 41 public:
40 explicit ElementsAccessor(const char* name) : name_(name) { } 42 explicit ElementsAccessor(const char* name) : name_(name) { }
41 virtual ~ElementsAccessor() { } 43 virtual ~ElementsAccessor() { }
42 44
43 virtual const char* name() const { return name_; } 45 virtual ElementsKind kind() const = 0;
46 const char* name() const { return name_; }
44 47
45 // Returns true if a holder contains an element with the specified key 48 // Returns true if a holder contains an element with the specified key
46 // without iterating up the prototype chain. The caller can optionally pass 49 // without iterating up the prototype chain. The caller can optionally pass
47 // in the backing store to use for the check, which must be compatible with 50 // in the backing store to use for the check, which must be compatible with
48 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the 51 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the
49 // holder->elements() is used as the backing store. 52 // holder->elements() is used as the backing store.
50 virtual bool HasElement(Object* receiver, 53 virtual bool HasElement(Object* receiver,
51 JSObject* holder, 54 JSObject* holder,
52 uint32_t key, 55 uint32_t key,
53 FixedArrayBase* backing_store = NULL) = 0; 56 FixedArrayBase* backing_store = NULL) = 0;
(...skipping 24 matching lines...) Expand all
78 // EcmaScript 5.1 semantics. 81 // EcmaScript 5.1 semantics.
79 virtual MaybeObject* SetCapacityAndLength(JSArray* array, 82 virtual MaybeObject* SetCapacityAndLength(JSArray* array,
80 int capacity, 83 int capacity,
81 int length) = 0; 84 int length) = 0;
82 85
83 // Deletes an element in an object, returning a new elements backing store. 86 // Deletes an element in an object, returning a new elements backing store.
84 virtual MaybeObject* Delete(JSObject* holder, 87 virtual MaybeObject* Delete(JSObject* holder,
85 uint32_t key, 88 uint32_t key,
86 JSReceiver::DeleteMode mode) = 0; 89 JSReceiver::DeleteMode mode) = 0;
87 90
91 virtual MaybeObject* CopyElements(JSObject* from_holder,
92 uint32_t from_start,
93 FixedArrayBase* to,
94 ElementsKind to_kind,
95 uint32_t to_start,
96 int copy_size,
97 FixedArrayBase* from = NULL) = 0;
Sven Panne 2012/03/09 08:15:18 Reading only this header, it is a bit confusing wh
danno 2012/03/09 12:12:35 Done.
98
99 MaybeObject* CopyElements(JSObject* from_holder,
100 FixedArrayBase* to,
101 ElementsKind to_kind,
102 FixedArrayBase* from = NULL) {
103 return CopyElements(from_holder, 0, to, to_kind, 0, -1, from);
104 }
105
88 virtual MaybeObject* AddElementsToFixedArray(Object* receiver, 106 virtual MaybeObject* AddElementsToFixedArray(Object* receiver,
89 JSObject* holder, 107 JSObject* holder,
90 FixedArray* to, 108 FixedArray* to,
91 FixedArrayBase* from = NULL) = 0; 109 FixedArrayBase* from = NULL) = 0;
92 110
93 // Returns a shared ElementsAccessor for the specified ElementsKind. 111 // Returns a shared ElementsAccessor for the specified ElementsKind.
94 static ElementsAccessor* ForKind(ElementsKind elements_kind) { 112 static ElementsAccessor* ForKind(ElementsKind elements_kind) {
95 ASSERT(elements_kind < kElementsKindCount); 113 ASSERT(elements_kind < kElementsKindCount);
96 return elements_accessors_[elements_kind]; 114 return elements_accessors_[elements_kind];
97 } 115 }
(...skipping 18 matching lines...) Expand all
116 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, 134 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
117 uint32_t index) = 0; 135 uint32_t index) = 0;
118 136
119 private: 137 private:
120 static ElementsAccessor** elements_accessors_; 138 static ElementsAccessor** elements_accessors_;
121 const char* name_; 139 const char* name_;
122 140
123 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); 141 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
124 }; 142 };
125 143
144
145 void CopyObjectToObjectElements(AssertNoAllocation* no_gc,
Sven Panne 2012/03/09 08:15:18 Hmmm, the first parameter is actually a phantom ty
danno 2012/03/09 12:12:35 Done.
146 FixedArray* from_obj,
147 ElementsKind from_kind,
148 uint32_t from_start,
149 FixedArray* to_obj,
150 ElementsKind to_kind,
151 uint32_t to_start,
152 int copy_size);
153
154
126 } } // namespace v8::internal 155 } } // namespace v8::internal
127 156
128 #endif // V8_ELEMENTS_H_ 157 #endif // V8_ELEMENTS_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/elements.cc » ('j') | src/elements.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698