Revision: 9277
Author: [email protected]
Date: Wed Sep 14 05:33:57 2011
Log: Make built-in functions not call .apply on functions.
Uses the new %Apply runtime function instead.
Removes last(?) dependency on user-mungable infrastructure.
Review URL: http://codereview.chromium.org/7887031
http://code.google.com/p/v8/source/detail?r=9277
Modified:
/branches/bleeding_edge/src/execution.cc
/branches/bleeding_edge/src/runtime.js
/branches/bleeding_edge/src/string.js
=======================================
--- /branches/bleeding_edge/src/execution.cc Wed Sep 14 00:30:51 2011
+++ /branches/bleeding_edge/src/execution.cc Wed Sep 14 05:33:57 2011
@@ -227,7 +227,7 @@
// If you return a function from here, it will be called when an
// attempt is made to call the given object as a function.
- // If object is a function proxies, get its handler. Iterate if
necessary.
+ // If object is a function proxy, get its handler. Iterate if necessary.
Object* fun = *object;
while (fun->IsJSFunctionProxy()) {
fun = JSFunctionProxy::cast(fun)->call_trap();
@@ -251,7 +251,7 @@
ASSERT(!object->IsJSFunction());
Isolate* isolate = Isolate::Current();
- // If object is a function proxies, get its handler. Iterate if
necessary.
+ // If object is a function proxy, get its handler. Iterate if necessary.
Object* fun = *object;
while (fun->IsJSFunctionProxy()) {
fun = JSFunctionProxy::cast(fun)->call_trap();
=======================================
--- /branches/bleeding_edge/src/runtime.js Tue Sep 13 04:42:57 2011
+++ /branches/bleeding_edge/src/runtime.js Wed Sep 14 05:33:57 2011
@@ -408,7 +408,7 @@
if (!IS_FUNCTION(delegate)) {
throw %MakeTypeError('called_non_callable', [typeof this]);
}
- return delegate.apply(this, arguments);
+ return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
}
@@ -417,7 +417,7 @@
if (!IS_FUNCTION(delegate)) {
throw %MakeTypeError('called_non_callable', [typeof this]);
}
- return delegate.apply(this, arguments);
+ return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
}
=======================================
--- /branches/bleeding_edge/src/string.js Tue Sep 13 04:42:57 2011
+++ /branches/bleeding_edge/src/string.js Wed Sep 14 05:33:57 2011
@@ -440,13 +440,14 @@
i++;
}
} else {
+ var receiver = %GetDefaultReceiver(replace);
while (i < len) {
var elem = res[i];
if (!%_IsSmi(elem)) {
// elem must be an Array.
// Use the apply argument as backing for global RegExp properties.
lastMatchInfoOverride = elem;
- var func_result = replace.apply(null, elem);
+ var func_result = %Apply(replace, receiver, elem, 0, elem.length);
res[i] = TO_STRING_INLINE(func_result);
}
i++;
@@ -472,11 +473,11 @@
// The number of captures plus one for the match.
var m = NUMBER_OF_CAPTURES(matchInfo) >> 1;
var replacement;
+ var receiver = %GetDefaultReceiver(replace);
if (m == 1) {
// 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 = %GetDefaultReceiver(replace);
replacement =
%_CallFunction(receiver, s, index, subject, replace);
} else {
@@ -487,7 +488,7 @@
parameters[j] = index;
parameters[j + 1] = subject;
- replacement = replace.apply(null, parameters);
+ replacement = %Apply(replace, receiver, parameters, 0, j + 2);
}
result.add(replacement); // The add method converts to string if
necessary.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev