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

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: 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 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..78339798c14de21bf6c602e25413a915b76c53fe 100644
--- a/src/runtime/runtime-interpreter.cc
+++ b/src/runtime/runtime-interpreter.cc
@@ -148,20 +148,52 @@ 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());
+ DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
- CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1);
- 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 triple such that cache_length is zero which'll
+ // coax ForInDone to quit on first attempt should the function
+ // return early.
+ Handle<FixedArray> result = isolate->factory()->NewFixedArray(3);
+ result->set(2, Smi::FromInt(0));
+ 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.
+ return *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 +217,23 @@ RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) {
}
}
- Handle<FixedArray> result = isolate->factory()->NewFixedArray(4);
- result->set(0, *receiver);
+ result->set(0, *cache_type);
result->set(1, *cache_array);
- result->set(2, *cache_type);
- result->set(3, Smi::FromInt(cache_length));
+ result->set(2, Smi::FromInt(cache_length));
return *result;
}
+RUNTIME_FUNCTION(Runtime_InterpreterToObjectOrNull) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+
+ Handle<JSReceiver> receiver;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, receiver,
+ ToObjectHelper(args.arguments(), isolate),
+ isolate->heap()->null_value());
+ return *receiver;
+}
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698