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

Side by Side Diff: src/accessors.cc

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 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/accessors.h ('k') | src/allocation-tracker.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 // 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int offset, 84 int offset,
85 int* object_offset) { 85 int* object_offset) {
86 if (name->Equals(property_name)) { 86 if (name->Equals(property_name)) {
87 *object_offset = offset; 87 *object_offset = offset;
88 return true; 88 return true;
89 } 89 }
90 return false; 90 return false;
91 } 91 }
92 92
93 93
94 bool Accessors::IsJSObjectFieldAccessor( 94 // Returns true for properties that are accessors to object fields.
95 Handle<Map> map, Handle<String> name, 95 // If true, *object_offset contains offset of object field.
96 int* object_offset) { 96 template <class T>
97 Isolate* isolate = map->GetIsolate(); 97 bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type,
98 Handle<String> name,
99 int* object_offset) {
100 Isolate* isolate = name->GetIsolate();
101
102 if (type->Is(T::String())) {
103 return CheckForName(name, isolate->heap()->length_string(),
104 String::kLengthOffset, object_offset);
105 }
106
107 if (!type->IsClass()) return false;
108 Handle<Map> map = type->AsClass();
109
98 switch (map->instance_type()) { 110 switch (map->instance_type()) {
99 case JS_ARRAY_TYPE: 111 case JS_ARRAY_TYPE:
100 return 112 return
101 CheckForName(name, isolate->heap()->length_string(), 113 CheckForName(name, isolate->heap()->length_string(),
102 JSArray::kLengthOffset, object_offset); 114 JSArray::kLengthOffset, object_offset);
103 case JS_TYPED_ARRAY_TYPE: 115 case JS_TYPED_ARRAY_TYPE:
104 return 116 return
105 CheckForName(name, isolate->heap()->length_string(), 117 CheckForName(name, isolate->heap()->length_string(),
106 JSTypedArray::kLengthOffset, object_offset) || 118 JSTypedArray::kLengthOffset, object_offset) ||
107 CheckForName(name, isolate->heap()->byte_length_string(), 119 CheckForName(name, isolate->heap()->byte_length_string(),
108 JSTypedArray::kByteLengthOffset, object_offset) || 120 JSTypedArray::kByteLengthOffset, object_offset) ||
109 CheckForName(name, isolate->heap()->byte_offset_string(), 121 CheckForName(name, isolate->heap()->byte_offset_string(),
110 JSTypedArray::kByteOffsetOffset, object_offset) || 122 JSTypedArray::kByteOffsetOffset, object_offset) ||
111 CheckForName(name, isolate->heap()->buffer_string(), 123 CheckForName(name, isolate->heap()->buffer_string(),
112 JSTypedArray::kBufferOffset, object_offset); 124 JSTypedArray::kBufferOffset, object_offset);
113 case JS_ARRAY_BUFFER_TYPE: 125 case JS_ARRAY_BUFFER_TYPE:
114 return 126 return
115 CheckForName(name, isolate->heap()->byte_length_string(), 127 CheckForName(name, isolate->heap()->byte_length_string(),
116 JSArrayBuffer::kByteLengthOffset, object_offset); 128 JSArrayBuffer::kByteLengthOffset, object_offset);
117 case JS_DATA_VIEW_TYPE: 129 case JS_DATA_VIEW_TYPE:
118 return 130 return
119 CheckForName(name, isolate->heap()->byte_length_string(), 131 CheckForName(name, isolate->heap()->byte_length_string(),
120 JSDataView::kByteLengthOffset, object_offset) || 132 JSDataView::kByteLengthOffset, object_offset) ||
121 CheckForName(name, isolate->heap()->byte_offset_string(), 133 CheckForName(name, isolate->heap()->byte_offset_string(),
122 JSDataView::kByteOffsetOffset, object_offset) || 134 JSDataView::kByteOffsetOffset, object_offset) ||
123 CheckForName(name, isolate->heap()->buffer_string(), 135 CheckForName(name, isolate->heap()->buffer_string(),
124 JSDataView::kBufferOffset, object_offset); 136 JSDataView::kBufferOffset, object_offset);
125 default: { 137 default:
126 if (map->instance_type() < FIRST_NONSTRING_TYPE) {
127 return
128 CheckForName(name, isolate->heap()->length_string(),
129 String::kLengthOffset, object_offset);
130 }
131 return false; 138 return false;
132 }
133 } 139 }
134 } 140 }
135 141
136 142
143 template
144 bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type,
145 Handle<String> name,
146 int* object_offset);
147
148
149 template
150 bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type,
151 Handle<String> name,
152 int* object_offset);
153
154
137 // 155 //
138 // Accessors::ArrayLength 156 // Accessors::ArrayLength
139 // 157 //
140 158
141 159
142 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, 160 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate,
143 Object* object, 161 Object* object,
144 void*) { 162 void*) {
145 // Traverse the prototype chain until we reach an array. 163 // Traverse the prototype chain until we reach an array.
146 JSArray* holder = FindInstanceOf<JSArray>(isolate, object); 164 JSArray* holder = FindInstanceOf<JSArray>(isolate, object);
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 Object); 717 Object);
700 } 718 }
701 719
702 720
703 static MaybeObject* ConstructArgumentsObjectForInlinedFunction( 721 static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
704 JavaScriptFrame* frame, 722 JavaScriptFrame* frame,
705 Handle<JSFunction> inlined_function, 723 Handle<JSFunction> inlined_function,
706 int inlined_frame_index) { 724 int inlined_frame_index) {
707 Isolate* isolate = inlined_function->GetIsolate(); 725 Isolate* isolate = inlined_function->GetIsolate();
708 Factory* factory = isolate->factory(); 726 Factory* factory = isolate->factory();
709 Vector<SlotRef> args_slots = 727 SlotRefValueBuilder slot_refs(
710 SlotRef::ComputeSlotMappingForArguments( 728 frame,
711 frame, 729 inlined_frame_index,
712 inlined_frame_index, 730 inlined_function->shared()->formal_parameter_count());
713 inlined_function->shared()->formal_parameter_count()); 731
714 int args_count = args_slots.length(); 732 int args_count = slot_refs.args_length();
715 Handle<JSObject> arguments = 733 Handle<JSObject> arguments =
716 factory->NewArgumentsObject(inlined_function, args_count); 734 factory->NewArgumentsObject(inlined_function, args_count);
717 Handle<FixedArray> array = factory->NewFixedArray(args_count); 735 Handle<FixedArray> array = factory->NewFixedArray(args_count);
736 slot_refs.Prepare(isolate);
718 for (int i = 0; i < args_count; ++i) { 737 for (int i = 0; i < args_count; ++i) {
719 Handle<Object> value = args_slots[i].GetValue(isolate); 738 Handle<Object> value = slot_refs.GetNext(isolate, 0);
720 array->set(i, *value); 739 array->set(i, *value);
721 } 740 }
741 slot_refs.Finish(isolate);
722 arguments->set_elements(*array); 742 arguments->set_elements(*array);
723 args_slots.Dispose();
724 743
725 // Return the freshly allocated arguments object. 744 // Return the freshly allocated arguments object.
726 return *arguments; 745 return *arguments;
727 } 746 }
728 747
729 748
730 MaybeObject* Accessors::FunctionGetArguments(Isolate* isolate, 749 MaybeObject* Accessors::FunctionGetArguments(Isolate* isolate,
731 Object* object, 750 Object* object,
732 void*) { 751 void*) {
733 HandleScope scope(isolate); 752 HandleScope scope(isolate);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 info->set_data(Smi::FromInt(index)); 988 info->set_data(Smi::FromInt(index));
970 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 989 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
971 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 990 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
972 info->set_getter(*getter); 991 info->set_getter(*getter);
973 if (!(attributes & ReadOnly)) info->set_setter(*setter); 992 if (!(attributes & ReadOnly)) info->set_setter(*setter);
974 return info; 993 return info;
975 } 994 }
976 995
977 996
978 } } // namespace v8::internal 997 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/allocation-tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698