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..26f71856a916c51c40806ddfe1a889e1eac01cef |
--- /dev/null |
+++ b/src/runtime/runtime-interpreter.cc |
@@ -0,0 +1,105 @@ |
+// 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* MaybeBooleanHelper(Isolate* isolate, Maybe<bool> result, |
+ bool negate = false) { |
+ if (result.IsJust()) { |
+ return isolate->heap()->ToBoolean(result.FromJust() ^ negate); |
+ } else { |
+ return isolate->heap()->exception(); |
+ } |
+} |
+ |
+ |
+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 MaybeBooleanHelper(isolate, Object::Equals(x, y)); |
Benedikt Meurer
2015/09/28 10:24:38
I'd really prefer to code it directly without the
oth
2015/09/28 10:38:45
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 MaybeBooleanHelper(isolate, Object::Equals(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 MaybeBooleanHelper(isolate, Object::LessThan(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 MaybeBooleanHelper(isolate, Object::GreaterThan(x, y)); |
+} |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_InterpreterLessThanOrEqual) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
+ return MaybeBooleanHelper(isolate, Object::LessThanOrEqual(x, y)); |
+} |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_InterpreterGreaterThanOrEqual) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
+ return MaybeBooleanHelper(isolate, Object::GreaterThanOrEqual(x, y)); |
+} |
+ |
+ |
+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 |