Commit Graph

100 Commits

Author SHA1 Message Date
mstarzinger@chromium.org
3d1582c474 Fix Array.prototype.join evaluation order.
R=yangguo@chromium.org
BUG=v8:2263
TEST=mjsunit/regress/regress-2263

Review URL: https://codereview.chromium.org/11280025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12989 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-11-16 12:45:23 +00:00
rossberg@chromium.org
af7bfe0e27 Minimal implementation and tests of observable array methods
Bail out of any special-casing in array methods.
Further optimization is possible, but can be left for later.

Review URL: https://codereview.chromium.org/11369151
Patch from Adam Klein <adamk@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12917 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-11-09 12:28:22 +00:00
rossberg@chromium.org
cd9029a502 Initial JS stub implementation of Object.observe. Adds support for .object/.unobserve/.notify/.deliverChangeRecords. No delivery mechanism is implemented for end-of-microtask.
Review URL: https://codereview.chromium.org/11225058
Patch from Rafael Weinstein <rafaelw@google.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12819 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-10-25 14:53:26 +00:00
yangguo@chromium.org
f910052543 Always invoke the default Array.sort functions from builtin functions, part 2.
R=vegorov@chromium.org
BUG=v8:2372

Review URL: https://chromiumcodereview.appspot.com/11175007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12774 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-10-19 12:30:18 +00:00
fschneider@chromium.org
971e834a8d Always invoke the default Array.sort functions from builtin functions.
TEST=mjsunit/regress/regress-builtin-array-op.js
BUG=v8:2372
Review URL: https://chromiumcodereview.appspot.com/10559005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12752 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-10-18 11:18:08 +00:00
erikcorry
f4f9e2c1e0 Quicksort: Choose pivot with recursive sort of pivot candidates on large arrays to avoid patholgical cases.
Review URL: http://codereview.chromium.org/10532193

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11873 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-06-20 07:52:47 +00:00
erikcorry
45c4cd26be Avoid arbitrarily deep recursion in Array.sort.
BUG=v8:2185
Review URL: http://codereview.chromium.org/10561017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11839 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-06-18 09:23:05 +00:00
erik.corry@gmail.com
3d45e98b5e Remove %_SwapElements. This inlined runtime contained an optimization that was dangerous in the presence of incremental compaction. It also prevented QuickSort from array.js from being optimized by Crankshaft, so it is probably better to do without it. We have high hopes that this will fix bug=117879.
Review URL: https://chromiumcodereview.appspot.com/10392150

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11588 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-05-17 20:53:32 +00:00
yangguo@chromium.org
f516037a6f Enable stepping into callback passed to builtins (e.g. Array.forEach).
BUG=109564
TEST=

Review URL: https://chromiumcodereview.appspot.com/10078014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11399 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-04-20 11:06:12 +00:00
mstarzinger@chromium.org
a918cd92af Fix handling of this in Array.prototype.concat method.
R=jkummerow@chromium.org
BUG=v8:2080
TEST=test262/15.4.4.4-5-c-i-1

Review URL: https://chromiumcodereview.appspot.com/10095006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11323 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-04-16 08:12:12 +00:00
rossberg@chromium.org
1336b913d0 Make built-ins strict mode conforming, and support a --use-strict flag.
* Turned all uses of 'const' into 'var'.
* Turned all uses of local 'function' into 'var'.
* Added a couple of missing toplevel 'var' declarations.

One consequence is that the properties on the builtin object  are no longer
non-writable, and I had to adapt one test. Is that a problem?

Unfortunately, we cannot actually switch the library scripts to strict mode
by default, because that makes observable things like poisoned .caller properties
for library functions.

Also removed dead flag code in Compiler::Compile.

R=yangguo@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9415010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10758 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-02-20 13:48:24 +00:00
mstarzinger@chromium.org
e423637898 Fix sequence of element access in array builtins.
R=rossberg@chromium.org
BUG=v8:1790
TEST=mjsunit/regress/regress-1790,test262/15.4.4.22-9-9

Review URL: https://chromiumcodereview.appspot.com/9419044

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10737 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-02-17 10:06:26 +00:00
erik.corry@gmail.com
70da367f6b More spelling changes.
Review URL: http://codereview.chromium.org/9231009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10407 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-01-16 12:38:59 +00:00
lrn@chromium.org
c7fccff9af Clean up JavaScript files to better follow coding standard.
Multiline conditionals must use braces.
Semicolons are not optional.

Review URL: http://codereview.chromium.org/8701006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10074 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-28 12:11:00 +00:00
mstarzinger@chromium.org
330cd2205c Remove hidden prototype for builtin functions.
This is a deliberate non-conformity introduced more than 2 years ago to
be compatible with JSC. The current state is that all other browsers
perform ES5 conform in that regard.

R=erik.corry@gmail.com
BUG=chromium:1717,chromium:39662
TEST=test262/15.2.3.6-4-6??,mjsunit/undeletable-functions

Review URL: http://codereview.chromium.org/8566009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9993 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-15 09:44:57 +00:00
yangguo@chromium.org
53c6077cee Fixing issue 103259.
BUG=103259
TEST=regress-103259.js

Review URL: http://codereview.chromium.org/8498011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9917 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-08 14:59:40 +00:00
mstarzinger@chromium.org
6742176949 Fix Array.filter to use internal array for result.
In built-in code we use arrays for internal computations. This makes it
possible to affect the built-in code by putting getters or setters on
the array prototype chain. Using internal arrays prevents those issues.

Related to: http://code.google.com/p/v8/source/detail?r=7040

R=svenpanne@chromium.org
TEST=test262/15.4.4.20-9-b-6

Review URL: http://codereview.chromium.org/8353006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9707 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-19 13:44:29 +00:00
mstarzinger@chromium.org
b3eba9e764 Fix handling of non-object receivers for array builtins.
R=svenpanne@chromium.org
BUG=chromium:100702
TEST=mjsunit/regress/regress-100702

Review URL: http://codereview.chromium.org/8347034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9693 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-19 09:24:37 +00:00
mstarzinger@chromium.org
e699434266 Fix some array functions to behave as specified.
This fixes the handling of primitives and the order of how side effects
are visible in some array functions as specified by the ES5.

R=rossberg@chromium.org
TEST=test262

Review URL: http://codereview.chromium.org/8197002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9549 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-07 14:07:33 +00:00
lrn@chromium.org
9f73eed45f Fix issue 1361 - Implement ES5 Array.prototype.toString.
BUG=v8:1361
TEST=mjsunit/array-tostring

Review URL: http://codereview.chromium.org/8124025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9519 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-05 07:08:23 +00:00
rossberg@chromium.org
e645597aa7 Implement function proxies (except for their use as constructors).
Introduce new %Apply native.

Extend Execution::Call to optionally handle receiver rewriting (needed for %Apply).

Fix Function.prototype.bind for functions that have .apply modified.

R=kmillikin@chromium.org
BUG=v8:1543
TEST=

Review URL: http://codereview.chromium.org/7623011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9258 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-13 11:42:57 +00:00
lrn@chromium.org
ffffa716c5 Lock the prototype of internal classes.
Prototypes and their properties and methods are locked down to prevent fiddling with their operation, even if the build-in object leaks.

Made some built-in functions only work during bootstrapping.

Review URL: http://codereview.chromium.org/7799027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9122 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-05 07:30:35 +00:00
lrn@chromium.org
5c32722581 Make built-in functions not rely on callback functions .call method.
In builtin code, we can't rely on Function.prototype.call being unmolested.

Review URL: http://codereview.chromium.org/7776008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9053 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-08-29 11:44:54 +00:00
lrn@chromium.org
cd3588d582 Make (some) functions called from builtin functions use the callback's global as receiver.
Changes GetGlobalReceiver() to GetDefaultReceiver(func) that returns undefined
for strict and native functions, and the function's context's global proxy
for "normal" functions.

BUG=v8:1547
TEST=cctest/api-test/ForeignFunctionReceiver

Review URL: http://codereview.chromium.org/7741042

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9030 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-08-26 13:53:00 +00:00
mstarzinger@chromium.org
2a225a3717 Fixed bug in array filter and reduce functions.
R=danno@chromium.org
BUG=v8:1559
TEST=test262

Review URL: http://codereview.chromium.org/7368005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8661 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-15 11:07:18 +00:00
ager@chromium.org
0d8c343c90 Do not pass the global object as the receiver to strict-mode and
builtin replace and sort functions.

R=ricow@chromium.org
BUG=v8:1360
TEST=mjsunit/regress/regress-1360.js

Review URL: http://codereview.chromium.org/7283006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8488 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-30 12:29:19 +00:00
ager@chromium.org
626cdffaef Fix Array.prototype.{reduce,reduceRight} to pass undefined as receiver for strict mode callbacks.
Propagate strict mode information from pre-parser to parser for lazily compiled functions.

R=lrn@chromium.org
BUG=v8:1436
TEST=mjsunit/regress/regress-1436.js

Review URL: http://codereview.chromium.org/7044054

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8227 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-09 09:05:15 +00:00
ager@chromium.org
0c1702b199 Don't use SmartSlice just because the receiver is an array.
Only do so if the estimated number of elements is low compared to the
end position for the slice. This is similar to other heuristics used
for array operations that use the %GetElementKeys runtime function.

R=erik.corry@gmail.com

Review URL: http://codereview.chromium.org/7111032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8184 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-06 13:28:44 +00:00
ricow@chromium.org
e0eb110130 Reapply 7763, including arm and x64 variants.
The only difference to revision 7763 is the implementation in the
builtins file for arm and x64, plus a move of Array.prototype.toString
and Array.prototype.toLocaleString from should throw on null or
undefined to the non generic test cases in the function-call test (due
to us not currently supporting generic cases with these to functions)
Review URL: http://codereview.chromium.org/6928007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7786 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-05 05:21:30 +00:00
ricow@chromium.org
4d890da191 Revert 7763, missing implementation on x64 and arm for call and apply with null or undefined.
Review URL: http://codereview.chromium.org/6913024

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7764 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-03 13:45:19 +00:00
ricow@chromium.org
2b730c2bf6 Don't exchange null and undefined with the global object in function.prototype.{call, apply} for natives.
This makes us compatible with firefox in throwing an exception when
call is invoked on a builtin with null as the this argument.
Review URL: http://codereview.chromium.org/6902104

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7763 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-03 13:19:04 +00:00
lrn@chromium.org
f470cf2777 Handle join of sparse arrays with non-empty separator more efficiently.
BUG=v8:1028

Review URL: http://codereview.chromium.org/6902144

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7716 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-29 08:53:36 +00:00
lrn@chromium.org
f5839996fb More cases of CallFunction that doesn't work correctly.
Review URL: http://codereview.chromium.org/6603015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7044 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-03 12:56:14 +00:00
lrn@chromium.org
30c0420b39 Undo change from .call to %_CallFunction.
The latter doesn't handle promotion of null/undefined to global object as
receiver for non-strict functions.

Review URL: http://codereview.chromium.org/6615013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7043 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-03 12:44:39 +00:00
lrn@chromium.org
4707d7ac08 Stop using plain Arrays internally in built-in functions.
In built-in code we use arrays for internal computations.
This makes it possible to affect the built-in code by putting getters
or setters on the Array prototype chain.
This adds a new internal Array constructor that creates Arrays with
a very simplistic prototype chain that doesn't include any publicly
visible objects. These Arrays shoudl ofcourse never leak outside the
builtins, since that would expose the prototype object.
The prototype object contains only the array functions that we use:
push, pop and join (and not even a toString, so it doesn't stringify
well).

Also change uses of .call to %_CallFunction.

BUG=1206

Review URL: http://codereview.chromium.org/6602081

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7040 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-03 11:49:03 +00:00
lrn@chromium.org
735dc96461 Fix bug 73940.
I think this actually turns the code in question into dead code, because the current definition of UseSparseVariant only allows arrays in DictionaryMode, and these never return encoded ranges from %GetArrayKeys. This is a subtle link between the definition of %GetArrayKeys and UseSparseVariant, so I would prefer to keep the code rather than having an invisible depeendency.

BUG=73940

Review URL: http://codereview.chromium.org/6596004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6946 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-25 11:30:22 +00:00
lrn@chromium.org
68f1c73a06 Fix array concat to follow the specification in the presence of element getters.
Also fix issue 1175 and 1177.

BUG=v8:1175

Review URL: http://codereview.chromium.org/6568007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6934 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-24 14:00:52 +00:00
antonm@chromium.org
186d832c79 Introduce new runtime function to make join with lower memory usage.
Do not use generic StringBuilderConcat which requires array passed
to keep both elements and separator (which roughly double size
of the array).  That should be faster as well.

BUG=crbug.com/54580

Review URL: http://codereview.chromium.org/6520004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6777 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-14 17:25:12 +00:00
sandholm@chromium.org
f64976e62d Improve ScanJsonNumber.
Review URL: http://codereview.chromium.org/6334106

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6658 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-07 08:57:06 +00:00
ager@chromium.org
471c0d2983 Avoid callbacks to user code during error formatting in a couple of
other situations.

Do not use overwritten Object.prototype.hasOwnProperty and
Array.prototype.pop. Do not use split and join in the error formatting
implementation. They are too big to control and their generality is
not needed.

Review URL: http://codereview.chromium.org/6287041

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6552 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-01 12:31:16 +00:00
antonm@chromium.org
a38a8ffab0 ArraySplice builtin should return empty array and not alter receiver if invoked with no arguments.
Review URL: http://codereview.chromium.org/6357025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6540 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-31 14:54:53 +00:00
sandholm@chromium.org
c260e4f731 Simplify Join and speedup joining arrays of numbers.
Review URL: http://codereview.chromium.org/6173004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6243 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-10 11:44:54 +00:00
sandholm@chromium.org
6dd671d6c2 Make better use of the %_FastAsciiArrayJoin function.
Review URL: http://codereview.chromium.org/6100005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6235 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-10 08:00:48 +00:00
sandholm@chromium.org
ba4f9faec5 Aviod double checking IS_STRING when joining arrays.
Review URL: http://codereview.chromium.org/5977013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6226 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-07 13:21:34 +00:00
lrn@chromium.org
5741575327 Tweak quicksort loop to reduce number of compares slightly.
Review URL: http://codereview.chromium.org/6039002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6087 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-20 14:57:51 +00:00
lrn@chromium.org
9f1bcdf8ac Change quicksort pivot from random to median-of-three.
Tweak quicksort bailout parameter to minimize time.

Review URL: http://codereview.chromium.org/5962003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6063 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-17 10:06:11 +00:00
sandholm@chromium.org
23c07cd413 Fix sputnik regression introduced in r5943.
Review URL: http://codereview.chromium.org/5516013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5944 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-08 09:52:48 +00:00
sandholm@chromium.org
b36e346a08 Use the PushIfAbsent function for the JSON stringify stack.
Optimize ConvertToString.
Review URL: http://codereview.chromium.org/5614004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5943 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-08 09:10:36 +00:00
sandholm@chromium.org
209eb1c219 Improved JSON stringify.
Review URL: http://codereview.chromium.org/5578004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5919 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-06 15:41:07 +00:00
whesse@chromium.org
1d11e32a01 Add a fast case to Array.join when all the elements and the separator are flat ascii strings.
Review URL: http://codereview.chromium.org/5122005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5860 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-11-19 09:25:46 +00:00