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

Unified Diff: src/objects-inl.h

Issue 1369293003: Wrap JSFunction bindings in a helper object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | src/profiler/heap-snapshot-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 3d39278cce9bd49437e76764f577900cdedb9ad0..96b3620a97458f0acfa482968d4f0b2257a84fdb 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -731,6 +731,7 @@ bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); }
bool Object::IsLiteralsArray() const { return IsFixedArray(); }
+bool Object::IsBindingsArray() const { return IsFixedArray(); }
bool Object::IsDeoptimizationInputData() const {
@@ -3506,6 +3507,75 @@ int LiteralsArray::literals_count() const {
}
+Object* BindingsArray::get(int index) const { return FixedArray::get(index); }
+
+
+void BindingsArray::set(int index, Object* value) {
+ FixedArray::set(index, value);
+}
+
+
+void BindingsArray::set(int index, Smi* value) {
+ FixedArray::set(index, value);
+}
+
+
+void BindingsArray::set(int index, Object* value, WriteBarrierMode mode) {
+ FixedArray::set(index, value, mode);
+}
+
+
+int BindingsArray::length() const { return FixedArray::length(); }
+
+
+BindingsArray* BindingsArray::cast(Object* object) {
+ SLOW_DCHECK(object->IsBindingsArray());
+ return reinterpret_cast<BindingsArray*>(object);
+}
+
+void BindingsArray::set_feedback_vector(TypeFeedbackVector* vector) {
+ set(kVectorIndex, vector);
+}
+
+
+TypeFeedbackVector* BindingsArray::feedback_vector() const {
+ return TypeFeedbackVector::cast(get(kVectorIndex));
+}
+
+
+JSReceiver* BindingsArray::bound_function() const {
+ return JSReceiver::cast(get(kBoundFunctionIndex));
+}
+
+
+void BindingsArray::set_bound_function(JSReceiver* function) {
+ set(kBoundFunctionIndex, function);
+}
+
+
+Object* BindingsArray::bound_this() const { return get(kBoundThisIndex); }
+
+
+void BindingsArray::set_bound_this(Object* bound_this) {
+ set(kBoundThisIndex, bound_this);
+}
+
+
+Object* BindingsArray::binding(int binding_index) const {
+ return get(kFirstBindingIndex + binding_index);
+}
+
+
+void BindingsArray::set_binding(int binding_index, Object* binding) {
+ set(kFirstBindingIndex + binding_index, binding);
+}
+
+
+int BindingsArray::bindings_count() const {
+ return length() - kFirstBindingIndex;
+}
+
+
void HandlerTable::SetRangeStart(int index, int value) {
set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value));
}
@@ -6322,13 +6392,13 @@ void JSFunction::set_literals(LiteralsArray* literals) {
}
-FixedArray* JSFunction::function_bindings() {
+BindingsArray* JSFunction::function_bindings() {
DCHECK(shared()->bound());
- return literals_or_bindings();
+ return BindingsArray::cast(literals_or_bindings());
}
-void JSFunction::set_function_bindings(FixedArray* bindings) {
+void JSFunction::set_function_bindings(BindingsArray* bindings) {
DCHECK(shared()->bound());
// Bound function literal may be initialized to the empty fixed array
// before the bindings are set.
« no previous file with comments | « src/objects.cc ('k') | src/profiler/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698