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

Unified Diff: src/js/string.js

Issue 1870993002: Revert of [builtins] Migrate String.prototype.charCodeAt and String.prototype.charAt to TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/js/messages.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/string.js
diff --git a/src/js/string.js b/src/js/string.js
index f0b970a0490d830a9b4b9e5a23bc16ed00d0aefc..ede5f881604b4ab2abaacba6c7a0a29be5db383e 100644
--- a/src/js/string.js
+++ b/src/js/string.js
@@ -54,6 +54,30 @@
throw MakeTypeError(kNotGeneric, 'String.prototype.valueOf');
}
return %_ValueOf(this);
+}
+
+
+// ECMA-262, section 15.5.4.4
+function StringCharAtJS(pos) {
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.charAt");
+
+ var result = %_StringCharAt(this, pos);
+ if (%_IsSmi(result)) {
+ result = %_StringCharAt(TO_STRING(this), TO_INTEGER(pos));
+ }
+ return result;
+}
+
+
+// ECMA-262 section 15.5.4.5
+function StringCharCodeAtJS(pos) {
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.charCodeAt");
+
+ var result = %_StringCharCodeAt(this, pos);
+ if (!%_IsSmi(result)) {
+ result = %_StringCharCodeAt(TO_STRING(this), TO_INTEGER(pos));
+ }
+ return result;
}
@@ -833,6 +857,13 @@
// -------------------------------------------------------------------
+// Set the String function and constructor.
+%FunctionSetPrototype(GlobalString, new GlobalString());
+
+// Set up the constructor property on the String prototype object.
+%AddNamedProperty(
+ GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
+
// Set up the non-enumerable functions on the String object.
utils.InstallFunctions(GlobalString, DONT_ENUM, [
"fromCharCode", StringFromCharCode,
@@ -844,6 +875,8 @@
utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf,
"toString", StringToString,
+ "charAt", StringCharAtJS,
+ "charCodeAt", StringCharCodeAtJS,
"codePointAt", StringCodePointAt,
"concat", StringConcat,
"endsWith", StringEndsWith,
@@ -889,6 +922,7 @@
utils.Export(function(to) {
to.ExpandReplacement = ExpandReplacement;
+ to.StringCharAt = StringCharAtJS;
to.StringIndexOf = StringIndexOf;
to.StringLastIndexOf = StringLastIndexOf;
to.StringMatch = StringMatchJS;
« no previous file with comments | « src/js/messages.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698