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

Unified Diff: src/runtime.cc

Issue 6531: - Added %IsArrayClass, %IsDateClass, and %IsStringClass.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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.h ('k') | src/runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 457)
+++ src/runtime.cc (working copy)
@@ -221,7 +221,31 @@
return JSObject::cast(obj)->class_name();
}
+inline static Object* IsSpecificClassOf(Arguments args, String* name) {
+ NoHandleAllocation ha;
+ ASSERT(args.length() == 1);
+ Object* obj = args[0];
+ if (obj->IsJSObject() && (JSObject::cast(obj)->class_name() == name)) {
+ return Heap::true_value();
+ }
+ return Heap::false_value();
+}
+static Object* Runtime_IsStringClass(Arguments args) {
+ return IsSpecificClassOf(args, Heap::String_symbol());
+}
+
+
+static Object* Runtime_IsDateClass(Arguments args) {
+ return IsSpecificClassOf(args, Heap::Date_symbol());
+}
+
+
+static Object* Runtime_IsArrayClass(Arguments args) {
+ return IsSpecificClassOf(args, Heap::Array_symbol());
+}
+
+
static Object* Runtime_IsInPrototypeChain(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -2508,8 +2532,12 @@
int len = x->length();
if (len != y->length()) return Smi::FromInt(NOT_EQUAL);
if (len == 0) return Smi::FromInt(EQUAL);
+
+ // Handle one elment strings.
+ if (x->Get(0) != y->Get(0)) return Smi::FromInt(NOT_EQUAL);
+ if (len == 1) return Smi::FromInt(EQUAL);
+
// Fast case: First, middle and last characters.
- if (x->Get(0) != y->Get(0)) return Smi::FromInt(NOT_EQUAL);
if (x->Get(len>>1) != y->Get(len>>1)) return Smi::FromInt(NOT_EQUAL);
if (x->Get(len - 1) != y->Get(len - 1)) return Smi::FromInt(NOT_EQUAL);
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698