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

Unified 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: Re-work ForInPrepare. 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime/runtime-interpreter.cc
diff --git a/src/runtime/runtime-interpreter.cc b/src/runtime/runtime-interpreter.cc
index c22e6808c3e19c763b35ab61d559b236638c5116..2f3cd0222ee2e534426a2d63e748d9f1f2574a6a 100644
--- a/src/runtime/runtime-interpreter.cc
+++ b/src/runtime/runtime-interpreter.cc
@@ -148,20 +148,51 @@ RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) {
}
+namespace {
+
+MaybeHandle<JSReceiver> ToObjectHelper(Object** args_object, Isolate* isolate) {
+ Object* o = Runtime_ToObject(1, args_object, isolate);
+ return MaybeHandle<JSReceiver>(handle(JSReceiver::cast(o), isolate));
+}
+
+
+MaybeHandle<Object> GetPropertyNamesFastHelper(Object** args_object,
+ Isolate* isolate) {
+ Object* o = Runtime_GetPropertyNamesFast(1, args_object, isolate);
+ return MaybeHandle<Object>(handle(Object::cast(o), isolate));
+}
+
+} // namespace
+
+
RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) {
HandleScope scope(isolate);
- DCHECK_EQ(2, args.length());
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
- CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1);
+ DCHECK_EQ(1, args.length());
- Handle<Object> cache_type = property_names;
- Handle<Map> cache_type_map = handle(property_names->map(), isolate);
- Handle<Map> receiver_map = handle(receiver->map(), isolate);
+ // Initialize return return triple such that cache_length is zero
rmcilroy 2015/12/17 15:43:27 extra "return"
oth 2015/12/17 19:28:24 Done.
+ // which'll coax ForInDone to quit on first attempt.
rmcilroy 2015/12/17 15:43:27 s/first attempt/first attempt if this function ret
oth 2015/12/17 19:28:24 Done.
+ Handle<FixedArray> result = isolate->factory()->NewFixedArray(4);
+ result->set(3, Smi::FromInt(0));
+
+ // Cast to accumulator
rmcilroy 2015/12/17 15:43:27 /a/accumulator/object
oth 2015/12/17 19:28:24 Done.
+ Handle<JSReceiver> receiver;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, receiver, ToObjectHelper(args.arguments(), isolate), *result);
+
+ Handle<Object> cache_type;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, cache_type,
+ GetPropertyNamesFastHelper(Handle<Object>::cast(receiver).location(),
+ isolate),
+ *result);
+ Handle<Map> receiver_map = handle(receiver->map(), isolate);
Handle<FixedArray> cache_array;
int cache_length;
-
- if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) {
+ if (cache_type->IsMap()) {
+ Handle<Map> cache_type_map =
+ handle(Handle<Map>::cast(cache_type)->map(), isolate);
+ DCHECK(cache_type_map.is_identical_to(isolate->factory()->meta_map()));
int enum_length = cache_type_map->EnumLength();
DescriptorArray* descriptors = receiver_map->instance_descriptors();
if (enum_length > 0 && descriptors->HasEnumCache()) {
@@ -185,14 +216,12 @@ RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) {
}
}
- Handle<FixedArray> result = isolate->factory()->NewFixedArray(4);
result->set(0, *receiver);
- result->set(1, *cache_array);
- result->set(2, *cache_type);
+ result->set(1, *cache_type);
+ result->set(2, *cache_array);
result->set(3, Smi::FromInt(cache_length));
return *result;
}
-
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698