summaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/runtime.js')
-rw-r--r--deps/v8/src/runtime.js102
1 files changed, 100 insertions, 2 deletions
diff --git a/deps/v8/src/runtime.js b/deps/v8/src/runtime.js
index 7d82dfa846..e4cb4ff312 100644
--- a/deps/v8/src/runtime.js
+++ b/deps/v8/src/runtime.js
@@ -418,7 +418,7 @@ function APPLY_PREPARE(args) {
// that takes care of more eventualities.
if (IS_ARRAY(args)) {
length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < 0x800000 &&
+ if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength &&
IS_SPEC_FUNCTION(this)) {
return length;
}
@@ -429,7 +429,7 @@ function APPLY_PREPARE(args) {
// 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 > 0x800000) {
+ if (length > kSafeArgumentsLength) {
throw %MakeRangeError('stack_overflow', []);
}
@@ -449,6 +449,93 @@ function APPLY_PREPARE(args) {
}
+function REFLECT_APPLY_PREPARE(args) {
+ var length;
+ // 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 &&
+ IS_SPEC_FUNCTION(this)) {
+ return length;
+ }
+ }
+
+ if (!IS_SPEC_FUNCTION(this)) {
+ throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
+ }
+
+ if (!IS_SPEC_OBJECT(args)) {
+ throw %MakeTypeError('reflect_apply_wrong_args', [ ]);
+ }
+
+ length = %ToLength(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 %MakeRangeError('stack_overflow', []);
+ }
+
+ // 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_SPEC_FUNCTION(this) && %IsConstructor(this);
+ var newTargetOk = IS_SPEC_FUNCTION(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_SPEC_FUNCTION(this)) {
+ throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
+ } else {
+ throw %MakeTypeError('not_constructor', [ %ToString(this) ]);
+ }
+ }
+
+ if (!newTargetOk) {
+ if (!IS_SPEC_FUNCTION(newTarget)) {
+ throw %MakeTypeError('called_non_callable', [ %ToString(newTarget) ]);
+ } else {
+ throw %MakeTypeError('not_constructor', [ %ToString(newTarget) ]);
+ }
+ }
+
+ if (!IS_SPEC_OBJECT(args)) {
+ throw %MakeTypeError('reflect_construct_wrong_args', [ ]);
+ }
+
+ length = %ToLength(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 %MakeRangeError('stack_overflow', []);
+ }
+
+ // 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 STACK_OVERFLOW(length) {
throw %MakeRangeError('stack_overflow', []);
}
@@ -694,3 +781,14 @@ function ToPositiveInteger(x, rangeErrorName) {
// that is cloned when running the code. It is essential that the
// boilerplate gets the right prototype.
%FunctionSetPrototype($Array, new $Array(0));
+
+
+/* -----------------------------------------------
+ - - - J a v a S c r i p t S t u b s - - -
+ -----------------------------------------------
+*/
+
+function STRING_LENGTH_STUB(name) {
+ var receiver = this; // implicit first parameter
+ return %_StringGetLength(%_JSValueGetValue(receiver));
+}