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

Unified Diff: src/runtime/runtime-forin.cc

Issue 1160983004: [turbofan] First step towards sanitizing for-in and making it optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add some comments. Created 5 years, 7 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/runtime/runtime-array.cc ('k') | src/runtime/runtime-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-forin.cc
diff --git a/src/runtime/runtime-forin.cc b/src/runtime/runtime-forin.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fadd2978379408c88bb2c7a1e1df963f6cd6963a
--- /dev/null
+++ b/src/runtime/runtime-forin.cc
@@ -0,0 +1,67 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/arguments.h"
+#include "src/runtime/runtime-utils.h"
+#include "src/v8.h"
+
+namespace v8 {
+namespace internal {
+
+RUNTIME_FUNCTION(Runtime_ForInDone) {
+ SealHandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_SMI_ARG_CHECKED(index, 0);
+ CONVERT_SMI_ARG_CHECKED(length, 1);
+ DCHECK_LE(0, index);
+ DCHECK_LE(index, length);
+ return isolate->heap()->ToBoolean(index == length);
+}
+
+
+RUNTIME_FUNCTION(Runtime_ForInFilter) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
+ // TODO(turbofan): Fast case for array indices.
+ Handle<Name> name = Runtime::ToName(isolate, key).ToHandleChecked();
+ Maybe<bool> result = JSReceiver::HasProperty(receiver, name);
+ if (result.IsJust() && result.FromJust()) return *name;
+ return isolate->heap()->undefined_value();
+}
+
+
+RUNTIME_FUNCTION(Runtime_ForInNext) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(4, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
+ CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2);
+ CONVERT_SMI_ARG_CHECKED(index, 3);
+ Handle<Object> key = handle(cache_array->get(index), isolate);
+ // Don't need filtering if expected map still matches that of the receiver,
+ // and neither for proxies.
+ if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) {
+ return *key;
+ }
+ // TODO(turbofan): Fast case for array indices.
+ Handle<Name> name = Runtime::ToName(isolate, key).ToHandleChecked();
+ Maybe<bool> result = JSReceiver::HasProperty(receiver, name);
+ if (result.IsJust() && result.FromJust()) return *name;
+ return isolate->heap()->undefined_value();
+}
+
+
+RUNTIME_FUNCTION(Runtime_ForInStep) {
+ SealHandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_SMI_ARG_CHECKED(index, 0);
+ DCHECK_LE(0, index);
+ DCHECK_LT(index, Smi::kMaxValue);
+ return Smi::FromInt(index + 1);
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | src/runtime/runtime-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698