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

Unified Diff: src/js/runtime.js

Issue 1523753002: [es6] Correct Function.prototype.apply, Reflect.construct and Reflect.apply. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mark mjsunit/apply as TIMEOUT (for tsan). Created 5 years 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/ia32/builtins-ia32.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/runtime.js
diff --git a/src/js/runtime.js b/src/js/runtime.js
index 300543e829e5be076ff8f7fd769f1a5abcb8b3f1..af5f2da84cdccd4b2176fe609aca30711feddd7f 100644
--- a/src/js/runtime.js
+++ b/src/js/runtime.js
@@ -34,127 +34,6 @@ utils.Import(function(from) {
-----------------------------
*/
-function APPLY_PREPARE(args) {
- var length;
-
- // First check that the receiver is callable.
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
- }
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
- return length;
- }
- }
-
- length = (args == null) ? 0 : TO_UINT32(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Make sure the arguments list has the right type.
- if (args != null && !IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Function.prototype.apply");
- }
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
-function REFLECT_APPLY_PREPARE(args) {
- var length;
-
- // First check that the receiver is callable.
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
- }
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
- return length;
- }
- }
-
- if (!IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Reflect.apply");
- }
-
- length = TO_LENGTH(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
-function REFLECT_CONSTRUCT_PREPARE(
- args, newTarget) {
- var length;
- var ctorOk = IS_CALLABLE(this) && %IsConstructor(this);
- var newTargetOk = IS_CALLABLE(newTarget) && %IsConstructor(newTarget);
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength &&
- ctorOk && newTargetOk) {
- return length;
- }
- }
-
- if (!ctorOk) {
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kCalledNonCallable, TO_STRING(this));
- } else {
- throw %make_type_error(kNotConstructor, TO_STRING(this));
- }
- }
-
- if (!newTargetOk) {
- if (!IS_CALLABLE(newTarget)) {
- throw %make_type_error(kCalledNonCallable, TO_STRING(newTarget));
- } else {
- throw %make_type_error(kNotConstructor, TO_STRING(newTarget));
- }
- }
-
- if (!IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Reflect.construct");
- }
-
- length = TO_LENGTH(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
function CONCAT_ITERABLE_TO_ARRAY(iterable) {
return %concat_iterable_to_array(this, iterable);
};
@@ -261,10 +140,7 @@ utils.Export(function(to) {
});
%InstallToContext([
- "apply_prepare_builtin", APPLY_PREPARE,
"concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
- "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
- "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
]);
%InstallToContext([
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698