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

Side by Side Diff: src/api.h

Issue 2196533003: [api] Cleaning up: Replace NeanderArray with FixedArray implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mind the pointers Created 4 years, 4 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
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 // 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 #ifndef V8_API_H_ 5 #ifndef V8_API_H_
6 #define V8_API_H_ 6 #define V8_API_H_
7 7
8 #include "include/v8-testing.h" 8 #include "include/v8-testing.h"
9 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 25 matching lines...) Expand all
36 explicit inline NeanderObject(v8::internal::Object* obj); 36 explicit inline NeanderObject(v8::internal::Object* obj);
37 inline v8::internal::Object* get(int index); 37 inline v8::internal::Object* get(int index);
38 inline void set(int index, v8::internal::Object* value); 38 inline void set(int index, v8::internal::Object* value);
39 inline v8::internal::Handle<v8::internal::JSObject> value() { return value_; } 39 inline v8::internal::Handle<v8::internal::JSObject> value() { return value_; }
40 int size(); 40 int size();
41 private: 41 private:
42 v8::internal::Handle<v8::internal::JSObject> value_; 42 v8::internal::Handle<v8::internal::JSObject> value_;
43 }; 43 };
44 44
45 45
46 // Utilities for working with neander-arrays, a simple extensible
47 // array abstraction built on neander-objects.
48 class NeanderArray {
49 public:
50 explicit NeanderArray(v8::internal::Isolate* isolate);
51 explicit inline NeanderArray(v8::internal::Handle<v8::internal::Object> obj);
52 inline v8::internal::Handle<v8::internal::JSObject> value() {
53 return obj_.value();
54 }
55
56 void add(internal::Isolate* isolate,
57 v8::internal::Handle<v8::internal::Object> value);
58
59 int length();
60
61 v8::internal::Object* get(int index);
62 // Change the value at an index to undefined value. If the index is
63 // out of bounds, the request is ignored. Returns the old value.
64 void set(int index, v8::internal::Object* value);
65 private:
66 NeanderObject obj_;
67 };
68
69
70 NeanderObject::NeanderObject(v8::internal::Handle<v8::internal::Object> obj) 46 NeanderObject::NeanderObject(v8::internal::Handle<v8::internal::Object> obj)
71 : value_(v8::internal::Handle<v8::internal::JSObject>::cast(obj)) { } 47 : value_(v8::internal::Handle<v8::internal::JSObject>::cast(obj)) { }
72 48
73 49
74 NeanderObject::NeanderObject(v8::internal::Object* obj) 50 NeanderObject::NeanderObject(v8::internal::Object* obj)
75 : value_(v8::internal::Handle<v8::internal::JSObject>( 51 : value_(v8::internal::Handle<v8::internal::JSObject>(
76 v8::internal::JSObject::cast(obj))) { } 52 v8::internal::JSObject::cast(obj))) { }
77 53
78 54
79 NeanderArray::NeanderArray(v8::internal::Handle<v8::internal::Object> obj)
80 : obj_(obj) { }
81
82
83 v8::internal::Object* NeanderObject::get(int offset) { 55 v8::internal::Object* NeanderObject::get(int offset) {
84 DCHECK(value()->HasFastObjectElements()); 56 DCHECK(value()->HasFastObjectElements());
85 return v8::internal::FixedArray::cast(value()->elements())->get(offset); 57 return v8::internal::FixedArray::cast(value()->elements())->get(offset);
86 } 58 }
87 59
88 60
89 void NeanderObject::set(int offset, v8::internal::Object* value) { 61 void NeanderObject::set(int offset, v8::internal::Object* value) {
90 DCHECK(value_->HasFastObjectElements()); 62 DCHECK(value_->HasFastObjectElements());
91 v8::internal::FixedArray::cast(value_->elements())->set(offset, value); 63 v8::internal::FixedArray::cast(value_->elements())->set(offset, value);
92 } 64 }
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 687 }
716 688
717 private: 689 private:
718 static v8::Testing::StressType stress_type_; 690 static v8::Testing::StressType stress_type_;
719 }; 691 };
720 692
721 } // namespace internal 693 } // namespace internal
722 } // namespace v8 694 } // namespace v8
723 695
724 #endif // V8_API_H_ 696 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698