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

Unified Diff: src/string.js

Issue 7283006: Do not pass the global object as the receiver to strict-mode and (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update sputnik status. Created 9 years, 6 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/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index bed211a031e4f9bec5b1604031fc41a0e73b0d00..01224e796aee2f2c4a3401c6efce5c9ff9ddb3ac 100644
--- a/src/string.js
+++ b/src/string.js
@@ -251,7 +251,9 @@ function StringReplace(search, replace) {
// Compute the string to replace with.
if (IS_FUNCTION(replace)) {
- builder.add(%_CallFunction(%GetGlobalReceiver(),
+ var receiver =
+ %_IsNativeOrStrictMode(replace) ? void 0 : %GetGlobalReceiver();
+ builder.add(%_CallFunction(receiver,
search,
start,
subject,
@@ -418,7 +420,8 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
if (NUMBER_OF_CAPTURES(lastMatchInfo) == 2) {
var match_start = 0;
var override = new InternalArray(null, 0, subject);
- var receiver = %GetGlobalReceiver();
+ var receiver =
+ %_IsNativeOrStrictMode(replace) ? void 0 : %GetGlobalReceiver();
while (i < len) {
var elem = res[i];
if (%_IsSmi(elem)) {
@@ -475,8 +478,10 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
// No captures, only the match, which is always valid.
var s = SubString(subject, index, endOfMatch);
// Don't call directly to avoid exposing the built-in global object.
+ var receiver =
+ %_IsNativeOrStrictMode(replace) ? void 0 : %GetGlobalReceiver();
replacement =
- %_CallFunction(%GetGlobalReceiver(), s, index, subject, replace);
+ %_CallFunction(receiver, s, index, subject, replace);
} else {
var parameters = new InternalArray(m + 2);
for (var j = 0; j < m; j++) {
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698