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

Side by Side Diff: src/runtime/runtime-interpreter.cc

Issue 1531693002: [Interpreter] Implement ForIn in bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Rebase after de-opt landed. Created 5 years 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 HandleScope scope(isolate); 141 HandleScope scope(isolate);
142 DCHECK_EQ(2, args.length()); 142 DCHECK_EQ(2, args.length());
143 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); 143 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
144 CONVERT_SMI_ARG_CHECKED(pretenured_flag, 1); 144 CONVERT_SMI_ARG_CHECKED(pretenured_flag, 1);
145 Handle<Context> context(isolate->context(), isolate); 145 Handle<Context> context(isolate->context(), isolate);
146 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( 146 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(
147 shared, context, static_cast<PretenureFlag>(pretenured_flag)); 147 shared, context, static_cast<PretenureFlag>(pretenured_flag));
148 } 148 }
149 149
150 150
151 namespace {
152
153 MaybeHandle<JSReceiver> ToObjectHelper(Object** args_object, Isolate* isolate) {
154 Object* o = Runtime_ToObject(1, args_object, isolate);
155 return MaybeHandle<JSReceiver>(handle(JSReceiver::cast(o), isolate));
156 }
157
158
159 MaybeHandle<Object> GetPropertyNamesFastHelper(Object** args_object,
160 Isolate* isolate) {
161 Object* o = Runtime_GetPropertyNamesFast(1, args_object, isolate);
162 return MaybeHandle<Object>(handle(Object::cast(o), isolate));
163 }
164
165 } // namespace
166
167
151 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { 168 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) {
152 HandleScope scope(isolate); 169 HandleScope scope(isolate);
153 DCHECK_EQ(2, args.length()); 170 DCHECK_EQ(1, args.length());
154 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 171 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
155 CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1);
156 172
157 Handle<Object> cache_type = property_names; 173 // Initialize return triple such that cache_length is zero which'll
158 Handle<Map> cache_type_map = handle(property_names->map(), isolate); 174 // coax ForInDone to quit on first attempt should the function
175 // return early.
176 Handle<FixedArray> result = isolate->factory()->NewFixedArray(3);
177 result->set(2, Smi::FromInt(0));
178
179 if (receiver->IsNull() || receiver->IsUndefined()) {
rmcilroy 2015/12/18 16:01:55 This won't be null given you have the branch in th
oth 2015/12/21 10:05:53 Done. This was stale.
180 return *result;
181 }
182
183 Handle<Object> cache_type;
184 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
185 isolate, cache_type,
186 GetPropertyNamesFastHelper(Handle<Object>::cast(receiver).location(),
187 isolate),
188 *result);
189
159 Handle<Map> receiver_map = handle(receiver->map(), isolate); 190 Handle<Map> receiver_map = handle(receiver->map(), isolate);
160
161 Handle<FixedArray> cache_array; 191 Handle<FixedArray> cache_array;
162 int cache_length; 192 int cache_length;
163 193 if (cache_type->IsMap()) {
164 if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) { 194 Handle<Map> cache_type_map =
195 handle(Handle<Map>::cast(cache_type)->map(), isolate);
196 DCHECK(cache_type_map.is_identical_to(isolate->factory()->meta_map()));
165 int enum_length = cache_type_map->EnumLength(); 197 int enum_length = cache_type_map->EnumLength();
166 DescriptorArray* descriptors = receiver_map->instance_descriptors(); 198 DescriptorArray* descriptors = receiver_map->instance_descriptors();
167 if (enum_length > 0 && descriptors->HasEnumCache()) { 199 if (enum_length > 0 && descriptors->HasEnumCache()) {
168 cache_array = handle(descriptors->GetEnumCache(), isolate); 200 cache_array = handle(descriptors->GetEnumCache(), isolate);
169 cache_length = cache_array->length(); 201 cache_length = cache_array->length();
170 } else { 202 } else {
171 cache_array = isolate->factory()->empty_fixed_array(); 203 cache_array = isolate->factory()->empty_fixed_array();
172 cache_length = 0; 204 cache_length = 0;
173 } 205 }
174 } else { 206 } else {
175 cache_array = Handle<FixedArray>::cast(cache_type); 207 cache_array = Handle<FixedArray>::cast(cache_type);
176 cache_length = cache_array->length(); 208 cache_length = cache_array->length();
177 209
178 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); 210 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE);
179 if (receiver_map->instance_type() == JS_PROXY_TYPE) { 211 if (receiver_map->instance_type() == JS_PROXY_TYPE) {
180 // Zero indicates proxy 212 // Zero indicates proxy
181 cache_type = Handle<Object>(Smi::FromInt(0), isolate); 213 cache_type = Handle<Object>(Smi::FromInt(0), isolate);
182 } else { 214 } else {
183 // One entails slow check 215 // One entails slow check
184 cache_type = Handle<Object>(Smi::FromInt(1), isolate); 216 cache_type = Handle<Object>(Smi::FromInt(1), isolate);
185 } 217 }
186 } 218 }
187 219
188 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); 220 result->set(0, *cache_type);
189 result->set(0, *receiver);
190 result->set(1, *cache_array); 221 result->set(1, *cache_array);
191 result->set(2, *cache_type); 222 result->set(2, Smi::FromInt(cache_length));
192 result->set(3, Smi::FromInt(cache_length));
193 return *result; 223 return *result;
194 } 224 }
195 225
196 226
227 RUNTIME_FUNCTION(Runtime_InterpreterToObjectOrNull) {
228 HandleScope scope(isolate);
229 DCHECK_EQ(1, args.length());
230
231 Handle<JSReceiver> receiver;
232 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
233 ToObjectHelper(args.arguments(), isolate),
234 isolate->heap()->null_value());
235 return *receiver;
236 }
237
197 } // namespace internal 238 } // namespace internal
198 } // namespace v8 239 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698