Commit Graph

137 Commits

Author SHA1 Message Date
Jeff Walden
d967e5e20f Bug 671143 - Rename ValueToNumber to ToNumber, to be more like the spec nomenclature. r=cdleary
--HG--
extra : rebase_source : e85fbadd77adc048f5e443cd9ed96b0035954674
2011-06-13 21:49:59 -07:00
Jeff Walden
1a51bb7cb1 Bug 645922 - Remove nsIJSON.encode/decode, because their functionality is subsumed by JSON.parse and JSON.stringify, and their idiosyncrasies are hindering code improvements. Also remove js_TryJSON and JS_TryJSON, which are no longer used after these changes and have no clear use cases. r=brendan, r=jst 2011-03-28 19:27:15 -07:00
Jeff Walden
4cf43e2ca4 Bug 657013 - Remove the old JSON parser. r=njn
--HG--
extra : rebase_source : 5c11e9179d2291d498667c17c05ff7e5f8ace3f2
2011-05-13 14:27:07 -07:00
Igor Bukanov
f4c246e790 bug 627016 - remove JSProperty out param from DefineNativeProperty. r=jorendorff
--HG--
extra : rebase_source : 673c7471fc963cb59d11ab667bd9e8523297617a
2011-01-21 14:10:16 +01:00
Jeff Walden
77b801ddde Bug 653888 - Clean up the Walk internal spec function, make the reviver delete properties from arrays if it returns undefined. r=pbiggar (relanding after a first try that appears to have triggered a random orange without methodjit on Linux debug, that went away on two rebuilds)
--HG--
extra : rebase_source : 4cef6936c39d63e232363baa64d24c0d1fabc60e
2011-05-05 00:24:15 -04:00
Jeff Walden
849fe0bfd1 Backed out changeset 83ae6e7c572e, maybe caused an orange, trying a backout of the most likely regressor. r=orange 2011-05-04 23:10:16 -04:00
Jeff Walden
e625314785 Bug 653888 - Clean up the Walk internal spec function, make the reviver delete properties from arrays if it returns undefined. r=pbiggar
--HG--
extra : rebase_source : 6d2004b0d6089c0c6d85bdaf4d4b0c8240840109
2011-04-30 03:22:48 -04:00
Jeff Walden
ca1b251411 Bug 653847 - JSON.parse should properly handle omitted arguments. r=pbiggar
--HG--
extra : rebase_source : 4ac9654d421a2504dbe24767fd5ffc0cbf52592e
2011-04-30 03:22:36 -04:00
Jeff Walden
eabb72c0f4 Bug 653782 - Properly handle JSON.stringify(_, replacer) when replacer isn't callable or an array. r=pbiggar
--HG--
extra : rebase_source : fed45c114091f45c0573f6d3cafef4ab0dd442b1
2011-04-30 03:22:11 -04:00
Jeff Walden
9361f3bfc8 Bug 653782 - Remove js_IndexToId, replace with an inline js::IndexToId. Also removes the redundant IndexToId in jsxml.cpp. r=igor
--HG--
extra : rebase_source : 4cb2b69a8f3d1877ca6514c8f9dfb3dc1af551b7
2011-04-30 03:19:26 -04:00
Jeff Walden
a6c5ef2297 Bug 643537 - Properly interpret String and Number objects provided as the space argument to JSON.stringify(value, replacer, space). r=pbiggar
--HG--
extra : rebase_source : 0d7e32f5ce57be2a1e341db7888df41033bbd2be
2011-03-18 18:20:15 -07:00
Jeff Walden
234a32b92a Bug 648471 - If JSON.stringify's replacer is an array, only get the list of property names to use from it once (i.e. invoke getters on the array only once), and get them in order from 0 to the array's initial length. Also use non-enumerable array index properties in addition to enumerable array index properties. r=pbiggar
--HG--
extra : rebase_source : 874e2502e5b5223feb19b457debc8cc8dc51e6cb
2011-04-11 01:46:12 -07:00
Paul Biggar
e4d6748cc4 Bug 642772: Don't recreate a class during enumeration, if it has been deleted (r=bhackett)
In SM, classes are lazily resolved. If we detect that a class about to be used
has not yet been resolved, then we resolve it. However, the way that we decided
that they were resolved was broken. If the global object had a String property,
then it had been resolved. So what happened when we deleted the String
property? Well, it got resolved again.

Instead of using the String property of the global object, we now use the
contructor slot on the global object. This works fine for String, but some
classes don't have a constructor, like Math and JSON. For those classes, we set
the constructor slot to True. In either case, we can now tell that a class is
resolved if the constructor slot in not Undefined.
2011-04-27 04:13:56 -07:00
Jeff Walden
af6649155f Bug 647385 - Implement a ToInteger helper that corresponds to the spec method (rather than inlining its contents everywhere it can be trivially used). Also fixes a couple bugs in one place that should have used ToInteger but didn't. r=cdleary 2011-04-02 11:33:20 -07:00
Jeff Walden
a0446bf092 Bug 512266 - JSON.stringify for various special characters should produce the corresponding one-character escapes. r=pbiggar
--HG--
extra : rebase_source : a76fb038143bd053ee9e30ae29e99d3c2e91c528
2011-03-18 17:57:18 -07:00
Luke Wagner
05d2002b66 Bug 644074 - Simplify and consolidate VM stack code into js/src/vm/Stack* 2011-04-13 09:27:37 -07:00
Luke Wagner
774c050740 Bug 602994 - Preparatory syntactic cleanup (r=waldo) 2011-04-08 10:52:48 -07:00
Luke Wagner
5653484fe5 Bug 587257 - Optimize Array.prototype.join (original patch by Rob Sayre) (r=waldo)
--HG--
extra : rebase_source : 9ca67ab914bb604736f6758e7f382f57563baf8f
2011-03-29 15:46:51 -07:00
Jeff Walden
f7ed22a8e1 Bug 589664 - Rewrite the JSON parser. r=njn, anticipating more review but getting it in-tree now for simplicity, even if more changes need to be made later 2011-03-23 16:34:53 -07:00
Jeff Walden
54bbd588ec Backed out changeset d2f2cac2e980, some compilers are complainy here and I don't immediately immediately and definitely see the problem -- to debug after backout. r=yunocompile 2011-04-08 09:29:44 -07:00
Jeff Walden
002069bfc8 Bug 589664 - Rewrite the JSON parser. r=njn, anticipating more review but getting it in-tree now for simplicity, even if more changes need to be made later 2011-03-23 16:34:53 -07:00
Jeff Walden
02e7d876a5 Bug 636079 - Refactor JSON.stringify code to more closely conform to the specification, fixing a bunch of known problems in the process. r=pbiggar
Bugs fixed:
* toJSON is now invoked with an argument list consisting of the property name.
* In rare circumstances toJSON was invoked twice for a single object-valued
  property.  This error has now been corrected.
* Stringification no longer throws if the toJSON property of an object being
  stringified is an object but is not callable.
* The replacer function is invoked exactly once for properties of objects
  when those properties are stringified.
* If a replacer function is to be called, it will receive array indexes as
  strings instead of numbers, per ES5.

Other improvements include:

* Speedier internal methods are used, rather than slow external APIs.
* Argument types are more specific (e.g. the "holder" argument is an object).
* Logic to determine when to call the replacer function is unnecessary and has
  been removed.

--HG--
extra : rebase_source : 1f2ee9ff4c14edebda3e48d33d6df32fc44b701d
2011-02-18 03:34:34 -08:00
Jeff Walden
b80782b484 Bug 643532 - Implement JS_ParseJSON and JS_ParseJSONWithReviver, a first step toward moving away from a begin-consume-finish-based JSON parsing process. r=luke 2011-03-21 11:42:06 -07:00
Jeff Walden
208cb6e474 Bug 645468 - Remove js_TryMethod: its semantics aren't what most of its users want, and its utility is limited. r=luke 2011-03-28 20:01:53 -07:00
Paul Biggar
72c7701093 Bug 634155: Account for NewCompartment's memory, and change allocation APIs (r=nnethercote)
This changes the allocation API, in the following way:

  js_malloc -> {cx->,rt->,OffTheBooks::}malloc
  js_calloc -> {cx->,rt->,OffTheBooks::}calloc
  js_realloc -> {cx->,rt->,OffTheBooks::}realloc
  js_free -> {cx->,rt->,Foreground::,UnwantedForeground::}free
  js_new -> {cx->,rt->,OffTheBooks::}new_
  js_new_array -> {cx->,rt->,OffTheBooks::}new_array
  js_delete -> {cx->,rt->,Foreground::,UnwantedForeground::}delete_

This is to move as many allocations as possible through a JSContext (so that they may be aken into account by gcMallocBytes) and to move as many deallocations to the background as possible (except on error paths).
2011-03-31 01:13:49 -07:00
Luke Wagner
7c96945e3c Bug 613457 - clean up string interfaces (r=njn)
--HG--
extra : rebase_source : 3e77b67fa9fe2cc31312ad99951cf92258a98e64
2011-03-14 13:59:53 -07:00
Jeff Walden
1f98843746 Bug 557371 - Make JSON.stringify behavior on Boolean, String, and Number objects to-spec. r=jorendorff 2010-12-31 11:41:23 -06:00
Andreas Gal
b126dc33dd Fix bug 635137 (r=luke, a=blocker). 2011-02-24 18:52:27 -08:00
Jim Blandy
de75b9fa19 Bug 537873: Add a 'strict' argument to C++ property setter functions. r=brendan
This changes the type of setters to JSStrictPropertyOp, which is just like
JSPropertyOp except that it takes a 'JSBool strict' argument. Most of the
patch is introducing distinct types and using the appropriate stubs.

The following are left for subsequent patches:

x Similar fixes to the browser outside SpiderMonkey.

x Actually *using* the newly available strictness information. This patch
  should have no user-visible effect. I didn't want the interesting stuff
  to get lost in this noise.
2011-02-09 11:31:40 -08:00
Jeff Walden
3de322ba70 Bug 629187 - Strict mode keywords are accepted as argument names and function name for strict mode functions. r=jimb
--HG--
extra : rebase_source : adce872db2d58e32a53995d757a85da50c8f63a4
2011-01-26 16:46:38 -08:00
Chris Leary
29a4e97a8f Bug 617935: Check string lengths using StringBuffer. (r=lw) 2011-01-12 15:28:58 -08:00
Jeff Walden
430108f273 Back out 567f16dd81f3, an existing test is bad, and by appearances poisoning of Boolean.prototype, Number.prototype, and String.prototype will make it hard to quickly fix. r=the O in ROYGBIV 2011-01-11 16:29:09 -06:00
Jeff Walden
0b3ec174d4 Bug 557371 - Make JSON.stringify behavior on Boolean, String, and Number objects to-spec. r=jorendorff
--HG--
extra : rebase_source : f329e9274b79abd264cf254d6d95a1b97f466ab9
2010-12-31 11:41:23 -06:00
Luke Wagner
d8719356c0 Bug 609440, part 4 - make JSString::chars() fallible (r=waldo,dvander,igor,dwitte,njn) 2010-12-06 10:26:58 -08:00
Paul Biggar
d5a5d3946f Bug 612292 - Rename array allocation functions (r=lw) 2010-12-13 16:22:59 -08:00
Jan de Mooij
96d0c8e0fa Bug 612989 - Try to convert numbers being parsed to int32 in JSON.parse. r=sayrer,jwalden 2010-11-17 21:54:29 +01:00
Nicholas Nethercote
2f1f144989 Bug 599254 - Avoid an unnecessary switch in the JSON parser. r=sayrer. 2010-09-27 17:20:43 -07:00
Gregor Wagner
fdb731becb Bug 558861 - Compartmental GC (r=gal) 2010-09-24 10:54:39 -07:00
Jim Blandy
ad83424ea2 Bug 594574: Change GetPropertyNames to take its out-parameter by address, not by non-const reference. r=brendan 2010-09-21 11:35:29 -07:00
Jim Blandy
2a3cf83056 Bug 537873, Bug 514574: Have strict mode code report TypeErrors for assignments, deletions. r=brendan
TODO: Fix error messages.
2010-09-15 13:43:55 -07:00
Nicholas Nethercote
837cae8aad Bug 590834 - Clean up number-to-string code. r=jwalden. 2010-09-13 13:08:25 -07:00
Jeff Walden
04a95a7188 Bug 564621, bug 582077 - JSON.parse shouldn't allow {"a" : "b",} or [1,]. But, because Firefox's bookmarks "JSON" generation has historically generated invalid JSON (it no longer does, see bug 505656), preserve a "legacy" mode of parsing that can be used to load bookmarks.json files (at least until we no longer support migration from Firefox <4 profiles :-) ). r=sayrer 2010-07-14 13:48:36 -05:00
Nicholas Nethercote
5d51c58e3d Fix typo in comment for patch in bug 578216. r=me. 2010-08-25 15:50:32 -07:00
Nicholas Nethercote
c5586f145a Bug 578216 - Make eval(json-like string) fast. r=sayrer 2010-08-24 11:50:54 -04:00
Nicholas Nethercote
2ab58fd02d Backed out changeset 74ce80e8782e 2010-08-23 22:38:19 -07:00
Nicholas Nethercote
7ba153876d Bug 578216 - Make eval(json-like string) fast. r=sayrer. 2010-08-23 18:13:09 -07:00
Jeff Walden
a8738dbbb2 Bug 584909 - Properly handle JSON.stringify(_1, _2, numberGreaterThanOne). Also output a space between ':' and property value when serializing object properties, if the gap specified is non-empty. r=sayrer
--HG--
extra : rebase_source : b4868a4a96d1ac89f389b47c0258d68e74e590a9
2010-08-09 16:39:19 -07:00
Jeff Walden
8ccd9fbe20 Bug 584909 - Use AutoIdVector/GetPropertyNames rather than AutoIdArray/JS_Enumerate to avoid unnecessary work and use cleaner APIs. r=sayrer
--HG--
extra : rebase_source : a8711da0c9423f9754a5ca01a2b7b3a26365cc9c
2010-08-09 16:39:19 -07:00
Paul Biggar
6634b70997 Split object/function allocation paths to avoid branch (578158, r=brendan). 2010-08-09 09:11:22 -07:00
Robert Sayre
fdb70f359e Change a comment to match the surrounding code. 2010-07-30 20:26:06 -07:00