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

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

Issue 1369123002: [Interpreter] Add interpreter support for compare ops and ToBoolean. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compilation fix. Created 5 years, 3 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.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-interpreter.cc
diff --git a/src/runtime/runtime-interpreter.cc b/src/runtime/runtime-interpreter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c68fbf6d52a1d1bec1a5055fee369a294fe19356
--- /dev/null
+++ b/src/runtime/runtime-interpreter.cc
@@ -0,0 +1,109 @@
+// 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/runtime/runtime-utils.h"
+
+#include "src/arguments.h"
+#include "src/isolate-inl.h"
+
+namespace v8 {
+namespace internal {
+
+
+static Object* ComparisonHelper(Isolate* isolate, ComparisonResult expected,
Benedikt Meurer 2015/09/28 09:05:23 Please don't write your own wrapper, but use Objec
oth 2015/09/28 10:23:02 Done.
+ Handle<Object> x, Handle<Object> y,
+ bool negate_result = false) {
+ Maybe<ComparisonResult> result = Object::Compare(x, y, Strength::WEAK);
+ if (!result.IsJust()) return isolate->heap()->exception();
+ ComparisonResult r = result.FromJust();
+ if (r == ComparisonResult::kUndefined) {
+ DCHECK(x->IsNaN() || y->IsNaN());
+ return isolate->heap()->false_value();
+ }
+ return isolate->heap()->ToBoolean((r == expected) ^ negate_result);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterEquals) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kEqual, x, y);
Benedikt Meurer 2015/09/28 09:05:23 Equals and NotEquals cannot use Compare; you need
oth 2015/09/28 10:23:02 Done.
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterNotEquals) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kEqual, x, y, true);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterLessThan) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kLessThan, x, y);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterGreaterThan) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kGreaterThan, x, y);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterLessThanEqual) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kGreaterThan, x, y, true);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterGreaterThanEqual) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
+ return ComparisonHelper(isolate, ComparisonResult::kLessThan, x, y, true);
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterStrictEquals) {
+ SealHandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_CHECKED(Object, x, 0);
+ CONVERT_ARG_CHECKED(Object, y, 1);
+ return isolate->heap()->ToBoolean(x->StrictEquals(y));
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterStrictNotEquals) {
+ SealHandleScope scope(isolate);
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_CHECKED(Object, x, 0);
+ CONVERT_ARG_CHECKED(Object, y, 1);
+ return isolate->heap()->ToBoolean(!x->StrictEquals(y));
+}
+
+
+RUNTIME_FUNCTION(Runtime_InterpreterCastToBoolean) {
+ SealHandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_CHECKED(Object, x, 0);
+ return isolate->heap()->ToBoolean(x->BooleanValue());
+}
+
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698