Commit Graph

2217 Commits

Author SHA1 Message Date
Leszek Swirski
9f6ddb48a0 Revert "V8 x64 backend doesn't emit ABI compliant stack frames"
This reverts commit 3cda21de77.

Reason for revert: Breaks the roll on Windows (see https://cr-buildbucket.appspot.com/build/8918477701097622400)

Original change's description:
> V8 x64 backend doesn't emit ABI compliant stack frames
> 
> On 64 bit Windows, the OS stack walking does not work because the V8 x64
> backend doesn't emit unwinding info and also because it doesn't emit ABI
> compliant stack frames. See
> https://docs.google.com/document/d/1-wf50jFlii0c_Pr52lm2ZU-49m220nhYMrHDi3vXnh0/edit
> for more details.
> 
> This problem can be fixed by observing that V8 frames usually all have the same
> prolog and epilog:
> 
> push rbp,
> mov rbp, rsp
> ...
> pop rbp
> ret N
> 
> and that it is possible to define XDATA (UNWIND_CODEs) that specify how Windows
> should walk through V8 frames. Furthermore, since V8 Code objects are all
> allocated in the same code-range for an Isolate, it is possible to register a
> single PDATA/XDATA entry to cover stack walking for all the code generated
> inside that code-range.
> 
> This PR contains changes required to enable stack walking on Win64:
> 
> EmbeddedFileWriter now adds assembler directives to the builtins
> snapshot source file (embedded.cc) to emit additional entries in the .pdata and
> in the .xdata section of the V8 executable. This takes care of stack walking
> for embedded builtins. (The case of non-embedded builtins is not supported).
> The x64 Assembler has been modified to collect the information required to emit
> this unwind info for builtins.
> 
> Stack walking for jitted code is handled is Isolate.cpp, by registering
> dynamically PDATA/XDATA for the whole code-range address space every time a new
> Isolate is initialized, and by unregistering them when the Isolate is
> destroyed.
> 
> Stack walking for WASM jitted code is handled is the same way in
> wasm::NativeModule (wasm/wasm-code-manager.cpp).
> 
> It is important to note that Crashpad and Breakpad are already registering
> PDATA/XDATA to manage and report unhandled exceptions (but not for embedded
> builtins). Since it is not possible to register multiple PDATA entries for the
> same address range, a new function is added to the V8 API:
> SetUnhandledExceptionCallback() can be used by an embedder to register its own
> unhandled exception handler for exceptions that arise in v8-generated code.
> V8 embedders should be modified accordingly (code for this is in a separate PR
> in the Chromium repository:
> https://chromium-review.googlesource.com/c/chromium/src/+/1474703).
> 
> All these changes are experimental, behind:
> 
> the 'v8_win64_unwinding_info' build flag, and
> the '--win64-unwinding-info' runtime flag.
> 
> Bug: v8:3598
> Change-Id: Iea455ab6d0e2bf1c556aa1cf870841d44ab6e4b1
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1469329
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Commit-Queue: Paolo Severini <paolosev@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#60330}

TBR=bbudge@chromium.org,ulan@chromium.org,mvstanton@chromium.org,mstarzinger@chromium.org,gdeepti@chromium.org,jgruber@chromium.org,paolosev@microsoft.com

Change-Id: If8470da94c58df8c800cbe8887f9f86236e43353
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:3598
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1532321
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60372}
2019-03-20 14:36:04 +00:00
Paolo Severini
3cda21de77 V8 x64 backend doesn't emit ABI compliant stack frames
On 64 bit Windows, the OS stack walking does not work because the V8 x64
backend doesn't emit unwinding info and also because it doesn't emit ABI
compliant stack frames. See
https://docs.google.com/document/d/1-wf50jFlii0c_Pr52lm2ZU-49m220nhYMrHDi3vXnh0/edit
for more details.

This problem can be fixed by observing that V8 frames usually all have the same
prolog and epilog:

push rbp,
mov rbp, rsp
...
pop rbp
ret N

and that it is possible to define XDATA (UNWIND_CODEs) that specify how Windows
should walk through V8 frames. Furthermore, since V8 Code objects are all
allocated in the same code-range for an Isolate, it is possible to register a
single PDATA/XDATA entry to cover stack walking for all the code generated
inside that code-range.

This PR contains changes required to enable stack walking on Win64:

EmbeddedFileWriter now adds assembler directives to the builtins
snapshot source file (embedded.cc) to emit additional entries in the .pdata and
in the .xdata section of the V8 executable. This takes care of stack walking
for embedded builtins. (The case of non-embedded builtins is not supported).
The x64 Assembler has been modified to collect the information required to emit
this unwind info for builtins.

Stack walking for jitted code is handled is Isolate.cpp, by registering
dynamically PDATA/XDATA for the whole code-range address space every time a new
Isolate is initialized, and by unregistering them when the Isolate is
destroyed.

Stack walking for WASM jitted code is handled is the same way in
wasm::NativeModule (wasm/wasm-code-manager.cpp).

It is important to note that Crashpad and Breakpad are already registering
PDATA/XDATA to manage and report unhandled exceptions (but not for embedded
builtins). Since it is not possible to register multiple PDATA entries for the
same address range, a new function is added to the V8 API:
SetUnhandledExceptionCallback() can be used by an embedder to register its own
unhandled exception handler for exceptions that arise in v8-generated code.
V8 embedders should be modified accordingly (code for this is in a separate PR
in the Chromium repository:
https://chromium-review.googlesource.com/c/chromium/src/+/1474703).

All these changes are experimental, behind:

the 'v8_win64_unwinding_info' build flag, and
the '--win64-unwinding-info' runtime flag.

Bug: v8:3598
Change-Id: Iea455ab6d0e2bf1c556aa1cf870841d44ab6e4b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1469329
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Paolo Severini <paolosev@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#60330}
2019-03-19 14:36:17 +00:00
Igor Sheludko
0188634ee5 [ptr-compr][ubsan] Use [Read/Write]UnalignedValue for unaligned fields
When pointer compression is enabled the [u]intptr_t and double fields are
only kTaggedSize aligned so in order to avoid undefined behavior in C++ code
we have to access these values in an unaligned pointer friendly way although
both x64 and arm64 architectures (where pointer compression is supported)
allow unaligned access.

These changes will be removed once v8:8875 is fixed and all the
kSystemPointerSize fields are properly aligned.

Bug: v8:7703
Change-Id: I4df477cbdeab806303bb4f675d52b61c06342c8e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1528996
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60321}
2019-03-19 11:34:31 +00:00
Benedikt Meurer
d6a60a0ee1 [turbofan] Significantly improve ConsString creation performance.
This change significantly improves the performance of string
concatenation in optimized code for the case where the resulting string
is represented as a ConsString. On the relevant test cases we go from

  serializeNaive: 10762 ms.
  serializeClever: 7813 ms.
  serializeConcat: 10271 ms.

to

  serializeNaive: 10278 ms.
  serializeClever: 5533 ms.
  serializeConcat: 10310 ms.

which represents a 30% improvement on the "clever" benchmark, which
tests specifically the ConsString creation performance.

This was accomplished via a couple of different steps, which are briefly
outlined here:

  1. The empty_string gets its own map, so that we can easily recognize
     and handle it appropriately in the TurboFan type system. This
     allows us to express (and assert) that the inputs to NewConsString
     are non-empty strings, making sure that TurboFan no longer creates
     "crippled ConsStrings" with empty left or right hand sides.
  2. Further split the existing String types in TurboFan to be able to
     distinguish between OneByte and TwoByte strings on the type system
     level. This allows us to avoid having to dynamically lookup the
     resulting ConsString map in case of ConsString creation (i.e. when
     we know that both input strings are OneByte strings or at least
     one of the input strings is TwoByte).
  3. We also introduced more finegrained feedback for the Add bytecode
     in the interpreter, having it collect feedback about ConsStrings,
     specifically ConsOneByteString and ConsTwoByteString. This feedback
     can be used by TurboFan to only inline the relevant code for what
     was seen so far. This allows us to remove the Octane/Splay specific
     magic in JSTypedLowering to detect ConsString creation, and instead
     purely rely on the feedback of what was seen so far (also making it
     possible to change the semantics of NewConsString to be a low-level
     operator, which is only introduced in SimplifiedLowering by looking
     at the input types of StringConcat).
  4. On top of the before mentioned type and interpreter changes we added
     new operators CheckNonEmptyString, CheckNonEmptyOneByteString, and
     CheckNonEmptyTwoByteString, which perform the appropriate (dynamic)
     checks.

There are several more improvements that are possible based on this, but
since the change was already quite big, we decided not to put everything
into the first change, but do some follow up tweaks to the type system,
and builtin optimizations later.

Tbr: mstarzinger@chromium.org
Bug: v8:8834, v8:8931, v8:8939, v8:8951
Change-Id: Ia24e17c6048bf2b04df966d3cd441f0edda05c93
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Doc: https://bit.ly/fast-string-concatenation-in-javascript
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499497
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60318}
2019-03-19 10:43:00 +00:00
Andrew Comminos
efa249a898 [cpu-profiler] Expose parent pointer in a CpuProfileNode
Consumers can use this to derive the full stack from sampled leaf nodes
without having to flatten the tree.

Bug: v8:8999
Change-Id: I42c638dd2c757837b0c03514c204be0182653291
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1525877
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60309}
2019-03-18 18:23:08 +00:00
Michael Lippautz
c8785d1572 [heap, api] Advance deprecations around global handles
Bug: chromium:923361, v8:8834
Change-Id: I46b6ad9eaa86476963a4e2cb3a5712447f180c20
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1528235
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60303}
2019-03-18 16:09:18 +00:00
Michael Lippautz
f4b860d9b8 [heap,api] Remove deprecated APIs
Bug: chromium:923361, v8:8834
Change-Id: I6ec42aeb74bea5c0629fcdc3f95c125f5de534a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1526195
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60289}
2019-03-18 12:51:22 +00:00
Leszek Swirski
d82c9afb8c [api] Add unique_ptr constructor for StreamedSource
Since StreamedSource takes ownership of the ExternalSourceStream
passed into it, it should take it by unique_ptr rather than raw
pointer to signal this transfer of ownership. The old constructor
is now deprecated.

Change-Id: I24681926c2f3141f7dd3664f72019a4c6deabfd7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1520713
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60232}
2019-03-14 09:42:26 +00:00
Simon Zünd
e5f01ba13f [cleanup] Remove unused stack_trace_ member from PromiseRejectMessage
R=yangguo@chromium.org

Bug: v8:8742
Change-Id: I307097021893617ed5178f1e967f9360a55cd929
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1520710
Auto-Submit: Simon Zünd <szuend@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60221}
2019-03-13 16:34:49 +00:00
Andrew Comminos
de7ab39a01 [cpu-profiler] Expose whether or not a script is shared cross origin in a CpuProfileNode
Enable cross-origin frame filtering by exposing this bit from
ScriptOriginOptions.

Bug: v8:8956
Change-Id: I109eec9db8b3d42d68d32abc5edd437b1c91a9b8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1493294
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60205}
2019-03-13 08:16:43 +00:00
Clemens Hammacher
d5f08e4e4f [api] Remove unowned Extensions interface
Extensions are now always passed via unique_ptr and are owned by V8.
This CL removes the deprecated API where the embedder would own the
Extension, but has no mechanism for deleting it.

R=ulan@chromium.org

Bug: v8:8725
Change-Id: Icb83660fad9d04c66f8db2265091ebabcbb197c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1514493
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60186}
2019-03-12 13:09:51 +00:00
Clemens Hammacher
6b09d21c8c [api] Remove deprecated WasmCompiledModule
Embedders should use WasmModuleObject instead.

R=adamk@chromium.org

Change-Id: Ibe5e4b160bb917bcd9f895be1b954acc40a045d8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1513616
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60184}
2019-03-12 11:50:05 +00:00
Anna Henningsen
f0bb5d2fcf [api] remove LegacyBuildEmbedderGraphCallback
This should not be used anymore (and it definitely is not by Node.js
or Chromium).

Change-Id: I4a1ce1fda98efd197a64ce0969dae5c8b18f6e97
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511484
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60139}
2019-03-09 08:38:05 +00:00
Michael Hablich
5b4ec1b550 Update V8 version to 7.5
NOTRY=true
TBR=machenbach@chromium.org

Change-Id: I0b8b93276e7724ef103924d17646599aef7b2ab4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1508212
Reviewed-by: Michael Hablich <hablich@chromium.org>
Commit-Queue: Michael Hablich <hablich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60088}
2019-03-07 12:24:49 +00:00
Dan Elphick
803fdb8f20 [docs] Change links from old wiki to v8.dev
Updates a bunch of links from https://github.com/v8/v8/wiki pages to the
appropriate v8.dev page that it redirected to anyway.

Bug: v8:8834
Change-Id: I5b37996900eb779753d97e487d16e1489f54d391
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1503473
Auto-Submit: Dan Elphick <delphick@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60086}
2019-03-07 12:13:30 +00:00
tzik
5b0510db7c Give the implementation of v8::MicrotaskQueue::New
This adds the entrypoint to MicrotaskQueue, which used to miss the
implementation.

Bug: v8:8124
Change-Id: I114fb69d975ee75c86b19349ca76789e425ea910
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1505232
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60076}
2019-03-07 04:40:37 +00:00
Jakob Kummerow
91f0cd0082 [ubsan] Fix various ClusterFuzz-found issues
Fixing a few float and int overflows.
Drive-by fix: with --experimental-wasm-bigint, Number values
may not be used to initialize i64-typed globals. The existing
code for doing that relied on UB; since it's a spec violation
the fix is to throw instead.

No regression test for 933103 because it will OOM anyway.
No regression test for 932896 because it would be extremely slow.

Bug: chromium:927894, chromium:927996, chromium:930086, chromium:932679, chromium:932896, chromium:933103, chromium:933134
Change-Id: Iae1c1ff1038af4512a52d3e56b8c4b75f2233314
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1495911
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60075}
2019-03-07 00:09:20 +00:00
Igor Sheludko
392316ddd1 [ptr-compr][x64] Define kTaggedSize as kInt32Size
... when pointer compression is enabled and some number of cleanups.

Bug: v8:7703
Change-Id: If7344abf68a1c4d54e4a79d066dc185f25055d7d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1477737
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60056}
2019-03-06 12:27:39 +00:00
tzik
2f79d68664 Deprecate MicrotasksCompletedCallback in favor to use *WithData version
This adds overloads of v8::Isolate::{Add,Remove}MicrotaskCompletedCallback,
that use MicrotasksCompletedCallbackWithData, and marks the original one
as V8_DEPRECATE_SOON for transition.

Bug: v8:8124
Change-Id: I124c3108545e1a2b29cd95620f36901431663c65
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1493766
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60045}
2019-03-06 08:08:09 +00:00
Igor Sheludko
1744803073 [ptr-compr] Prepare for changing kTaggedSize, pt.3
This CL also gives up trying to maintain double and system word
fields at aligned addresses because currently it's not always
maintained (v8:8875) and Torque object definitions do not support
padding fields (v8:8863).

Given that both platforms where pointer compression is going to be
enabled (x64 and arm64) support loading of doubles and full words
from 4-byte aligned addresses we are fine.

Bug: v8:7703
Change-Id: I99fc6da5a0927f4db9b8fb24c7cc0bfc416523bc
Reviewed-on: https://chromium-review.googlesource.com/c/1496974
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60013}
2019-03-04 15:40:02 +00:00
Benedikt Meurer
683cf6f43b [cleanup] Remove obsolete "one byte data hint" for strings.
In the early days of Chrome when we used WebKit there was no support for
ASCII strings on the C++ side, so we put a hint onto these two-byte
strings that said "string only contains one byte data", such that
internally in V8 when these were involved in string operations, we could
instead create the *cheaper* one byte strings.

Nowadays Blink properly supports one-byte string representations and
this additional hint only comes with overhead, since we check it in
quite a few places (i.e. on the hot path for string concatenation), plus
we end up consuming more memory due to the additional string maps.
Removing the hint also frees one bit in the InstanceType zoo for
strings.

This alone improves performance on the `bench-dom-serialize.js` test case
by around **3%**.

Tbr: mstarzinger@chromium.org
Bug: v8:6622, v8:8834, v8:8939
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I0753f2859cee7b5a37b6f0da64d8ec39fcb044ff
Doc: https://bit.ly/fast-string-concatenation-in-javascript
Reviewed-on: https://chromium-review.googlesource.com/c/1498478
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60006}
2019-03-04 14:04:02 +00:00
Dan Elphick
980e0d32d0 [api] Add new configuration change methods
This adds a new method Isolate::LocaleConfigurationChangeNotification
that clears the cached Locale allowing new Locales to be picked up in
later Locale operations.

It moves Date::DateTimeConfigurationChangeNotification to Isolate
(deprecating the old one) so that the configuration change methods are
found together.

Change-Id: Iffc15e326933c5bc5baf2f0eafdd5c148b8279a8
Reviewed-on: https://chromium-review.googlesource.com/c/1491608
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60003}
2019-03-04 12:56:51 +00:00
Clemens Hammacher
3f8b031647 [zone] Remove segment pooling from accounting allocator
This pooling introduces severe lock contention for Liftoff compilation,
since each compilation uses its own Zone which does at least one
segment allocation.
It's also unclear whether pooling improves performance, since {malloc}
should implement a similar pooling mechanism, but better optimized for
multithreaded uses.

Feel free to revert if this introduces significant regressions.

R=verwaest@chromium.org

Bug: v8:8916
Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel
Change-Id: Iaf988bed898e35700f5f7f3310df8e01918de4c9
Reviewed-on: https://chromium-review.googlesource.com/c/1491632
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59959}
2019-03-01 09:25:48 +00:00
tzik
cce33f3752 Expose MicrotaskQueue as a V8 API
This introduces v8::MicrotaskQueue backed by v8::internal::MicrotaskQueue.

The embedder will get an option to use non-default MicrotaskQueue by creating
the instance by v8::MicrotaskQueue::New(). The instance can be attached to
a Context by passing it to Context::New().

Bug: v8:8124
Change-Id: Iee0711785d5748860eb94e30a8d83199a743ffaa
Reviewed-on: https://chromium-review.googlesource.com/c/1414950
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59933}
2019-02-28 09:02:26 +00:00
Michael Lippautz
7b6a7379b6 PersistentValueMapBase: Deprecate outdated marking API
Embedders should use EmbedderHeapTracer::RegisterEmbedderReference
instead.

Bug: chromium:923361
Change-Id: If76c0354475798b09af95bedee0890594b29cd14
Reviewed-on: https://chromium-review.googlesource.com/c/1486472
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59840}
2019-02-25 16:43:33 +00:00
Peter Marshall
51e80efd12 [tracing] Fix races in TracingController implementation
The default TracingController (used by d8 and Node) has some concurrency
issues. The new test flushes these out, when a second thread logs trace
events while the main thread calls StopTracing().

- Use an acquire load in UpdateCategoryGroupEnabledFlags() because this
  was racing with GetCategoryGroupEnabled() where a new category is
  added in the slow path. g_category_groups is append-only, but
  reads/writes to g_category_index need to be correctly ordered so that
  new categories are added and only then is the change to the index
  visible. The relaxed load ignored this and caused unsynchronized
  read/write.
- Use a relaxed load in ~ScopedTracer() to access category_group_enabled
  as this previously used a non-atomic operation which caused a race
  with UpdateCategoryGroupEnabledFlag() which does a relaxed store.
- Replace TracingController::mode_ with an atomic bool as read/writes to
  mode_ were not synchronized and caused TSAN errors. It only has two
  states and it doesn't seem like we will extend this so just convert it
  to bool.
- Take the lock around calling trace_object->Initialize in
  AddTraceEvent(), and around trace_buffer_->Flush() in StopTracing().
  These two raced previously as the underlying TraceBufferRingBuffer
  passes out pointers to TraceObjects in a synchronized way, but the
  caller (AddTraceEvent) then writes into the object without
  synchronization. This leads to races when Flush() is called, at which
  time TraceBufferRingBuffer assumes that all the pointers it handed out
  are to valid, initialized TraceObjects - which is not true because
  AddTraceEvent may still be calling Initialize on them. This could be
  the cause of issues in Node.js where the last line of tracing/logging
  sometimes gets cut off. This is kind of a band-aid solution - access
  to the TraceObjects handed out by the ring buffer really needs proper
  synchronization which at this point would require redesign. It's quite
  likely we will replace this with Perfetto in the near future so not
  much point investing in this code right now.
- Enable TracingCpuProfiler test which was flaky due to these bugs.

Bug: v8:8821
Change-Id: I141296800c6906ac0e7f3f21dd16d861b07dae62
Reviewed-on: https://chromium-review.googlesource.com/c/1477283
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Ali Ijaz Sheikh <ofrobots@google.com>
Cr-Commit-Position: refs/heads/master@{#59752}
2019-02-21 08:34:16 +00:00
Frank Tang
4868ee165a [Intl] Track Usage for String.prototype.normalize
Bug: v8:8844
Change-Id: Id0e52a3367d641205e2f1c67d610254708fd4494
Reviewed-on: https://chromium-review.googlesource.com/c/1470813
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59714}
2019-02-20 03:41:27 +00:00
Peter Marshall
27f5c10140 [cleanup] Clean up tracing-controller.cc
- Switch #define constant to static const
- Remove unnecessary Internal version of GetCategoryGroupEnabled()
- Fix a typo in a comment

Change-Id: I4af71dc62c7c4742bdfbcaa1ad336298eb325c42
Reviewed-on: https://chromium-review.googlesource.com/c/1477221
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59708}
2019-02-19 19:44:25 +00:00
Anna Henningsen
d3308d042c [api] Add Isolate::GetArrayBufferAllocator()
This allows non-monolithic embedders to always allocate memory
for ArrayBuffer instances using the right allocation method.

This is based on a patch that Electron is currently using.

Refs: 1898f91620/patches/common/v8/array_buffer.patch
Change-Id: I39a614343118a0594aab48699a99cc2aad5b7ba9
Reviewed-on: https://chromium-review.googlesource.com/c/1462003
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59697}
2019-02-19 16:02:42 +00:00
Ulan Degenbaev
d342122f26 [heap] Use non-nestable delayed tasks in incremental marking job
Bug: chromium:926189
Change-Id: Ibd90f3cfdb37f07f3668f9ad79cff6e4305dc874
Reviewed-on: https://chromium-review.googlesource.com/c/1477674
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59688}
2019-02-19 14:15:06 +00:00
Sigurd Schneider
2f8a5f595f [api] Add enum type to RAILMode to allow forward-declaration of enum
This allows removing some v8.h includes in blink, and replacing them by
forward declarations.

Change-Id: I3f55669f551e29038918f54a26a0ab032ffb252a
Bug: v8:8788
Reviewed-on: https://chromium-review.googlesource.com/c/1475394
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59630}
2019-02-15 13:08:56 +00:00
Hannu Trey
f781f522af Re-detect the host time zone if requested by an embedder
Add an enum argument to DateTimeConfigurationChangeNotification to
control whether or not to redetect the host time zone. The default value
kSkip doesn't cause redetecting so that callers do not need to change if
they want the current behavior (e.g. Chromium).

Note that the host time zone detection does not work when v8 is run
inside a sandbox as in Chromium so that Chromium detects the host time
zone outside the sandbox before calling
DateTimeConfigurationChangeNotification. OTOH, other v8 embedders may
find it more convenient for v8 to do the host time zone detection on
their behalf. In that case, they can call the function with the new
argument set to value kRedetect.

Test:
With PHP+V8Js on linux, execute:
php -r '
  putenv("TZ=Europe/Helsinki");
  $v8 = new V8Js();
  $v8->executeString("print((new Date(0)).toString()+\"\\n\");");
  putenv("TZ=America/New_York");
  $v8->executeString("print((new Date(0)).toString()+\"\\n\");");'

Result before modification:
Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)

Result after modification:
Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)

Result after V8JS is modified to use value kRedetect when calling

Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time)

DateTimeConfigurationChangeNotification: 
Change-Id: I005192dd42669a94f606a49baa9eafad3475b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/1449637
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Jungshik Shin <jshin@chromium.org>
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59613}
2019-02-14 23:40:23 +00:00
Anna Henningsen
4325ebb29d [api] Remove warning about ValueSerializer
This API has existed for two and a half years now, with no
API changes over the last year, and is widely used in production,
code so it makes sense to consider it stable.

Change-Id: I10e38c37fb8c13e22124ef0985f4b0bd8d4615fd
Reviewed-on: https://chromium-review.googlesource.com/c/1461999
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59576}
2019-02-13 17:40:18 +00:00
tzik
df95cff995 Move MicrotasksPolicy management to MicrotaskQueue
This CL moves MicrotasksPolicy from Isolate's HandleScopeImplementer
to MicrotaskQueue for better non-default MicrotaskQueue support.

After this:
 * MicrotaskPolicy is per-MicrotaskQueue rather than single global one.
 * ENTER_V8 runs MicrotaskQueue associated to the current Context, rather
   than the default_microtask_queue().
 * SuppressMicrotaskExecutionScope and MicrotasksScope are ready to
   take MicrotaskQueue parameter, rather than using the default one.

Note that there's no way to use a non-default microtask queue until we
expose it as a V8 API.

Bug: v8:8124
Change-Id: I79cbc53d26d9f3f4cfb7c64d303b12e395b76815
Reviewed-on: https://chromium-review.googlesource.com/c/1429720
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59517}
2019-02-12 06:06:15 +00:00
Dan Elphick
cbd8f4269f [api] Remove several deprecated methods
Removes deprecated platform::CreateDefaultPlatform,
Object::GetPropertNames/GetOwnPropertyNames/HasRealNamedProperty/
HasRealIndexedProperty/HasRealNamedCallbackProperty,
Function::New/Call and Isolate::SetWasmCompileStreamingCallback.

Change-Id: I00c73576bbfbdc6bbe72bad9ac9d7a338a5bf068
Reviewed-on: https://chromium-review.googlesource.com/c/1460952
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59510}
2019-02-11 16:55:11 +00:00
Toon Verwaest
b9af6ad89d [api] Mark SetHiddenPrototype as DEPRECATED
Change-Id: Iad53e1a3b6ef0148dc5aa9c5c04c25c446dcdfa2
Reviewed-on: https://chromium-review.googlesource.com/c/1460468
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59464}
2019-02-08 14:49:30 +00:00
Yang Guo
9b2bcf57ba Expose protected v8::Platform::SystemClockTimeMillis
This allows the embedder to use a shared library build
even if they use this method.

R=ulan@chromium.org

Change-Id: I613a6e5eb82b494128fb95dc89a0b73639ac5ca2
Reviewed-on: https://chromium-review.googlesource.com/c/1456042
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59455}
2019-02-08 12:49:19 +00:00
Dan Elphick
c6d2169183 [api] Advance deprecation for Value::BooleanValue
Mark Context version of BooleanValue as V8_DEPRECATED.

Bug: v8:7279, v8:8562
Change-Id: I152f5080d92a940dadea9e8f2ed3f25338e6f099
Reviewed-on: https://chromium-review.googlesource.com/c/1458245
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59452}
2019-02-08 11:33:07 +00:00
Clemens Hammacher
c4411b0be8 [api] Deprecate legacy RegisterExtension method
The new API receives a unique_ptr to avoid leaking the Extension object.
All chromium uses were refactored in https://crrev.com/c/1447652.

R=adamk@chromium.org

Bug: v8:8725
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I46a931a73e941fe7b78f5390fec74663677e13e4
Reviewed-on: https://chromium-review.googlesource.com/c/1454723
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59451}
2019-02-08 10:55:17 +00:00
Mythri
648ba1f7dd Defer inferring language mode for PropertyCallbackInfo
This cl: https://chromium-review.googlesource.com/c/v8/v8/+/1421077
changed the implementation of SetProperty to infer the language mode.
Language mode is only required when there is an error to decide if we
have to throw an error or not. However we used to compute language mode
eagerly for PropertyCallbackInfo. This causes regressions in some
benchmarks. This cl changes it by deferring it further by computing
it only when it is actually required.

BUG: v8:8580, chromium:925289
Change-Id: Iba70ec5f9bb3deec16414a1ec418b3963f2144f9
Reviewed-on: https://chromium-review.googlesource.com/c/1454608
Reviewed-by: Adam Klein <adamk@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59450}
2019-02-08 10:24:27 +00:00
Michael Lippautz
edef7f1341 [api,global-handle] Introduce TracedGlobal::SetFinalizationCallback
Introduce a way to set a custom finalization callback that can be used
to signal and set up destruction of embedder memory.

Bug: chromium:923361
Change-Id: Ifc62ebd534aba3b02511c74b59161ec3edc0ee0d
Reviewed-on: https://chromium-review.googlesource.com/c/1452447
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59381}
2019-02-05 21:46:07 +00:00
Ross McIlroy
6f5e805284 [Cleanup] Delete deprecated FunctionTemplate::GetFunction API.
BUG=v8:7295,v8:8562

Change-Id: Ifa02ba233967ba38d4ff43576de77738001d076a
Reviewed-on: https://chromium-review.googlesource.com/c/1450115
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59330}
2019-02-04 10:58:48 +00:00
Ross McIlroy
2cbfbc2a1d [Cleanup] Delete deprecated ObjectTemplate::NewInstance() API
BUG=v8:7294,v8:8562

Change-Id: I1ed3b6d6a2fed2aee224e22ae8db5d76a52998a5
Reviewed-on: https://chromium-review.googlesource.com/c/1449731
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59301}
2019-02-01 16:47:35 +00:00
Michael Lippautz
96315d1622 [api] Mark old method for tracing as soon deprecated
Users should switch to TracedGlobal and the newly added methods of
v8::EmbedderHeapTracer.

Bug: chromium:923361, v8:8562
Change-Id: I3e5ed5785a0a49c0b65c7b1d1d103e568dd3e938
Reviewed-on: https://chromium-review.googlesource.com/c/1445752
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59297}
2019-02-01 14:51:34 +00:00
Ross McIlroy
cbeeb86baa [Cleanup] Delete deprecated ExternalOneByteStringResourceImpl and IsCompressible
BUG=v8:8395

Change-Id: I717f4c35fb9764a2ffb97662eef0148ad04284e6
Reviewed-on: https://chromium-review.googlesource.com/c/1449633
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59294}
2019-02-01 14:27:50 +00:00
Ross McIlroy
30c1199f77 [Cleanup] Delete deprecated RegisterDefaultTrapHandler API.
BUG=v8:8562

Change-Id: I66b729aeb306ecfbf92ee6e992c3abb6f854949c
Reviewed-on: https://chromium-review.googlesource.com/c/1449733
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59290}
2019-02-01 13:13:10 +00:00
Clemens Hammacher
7539549e28 [api] Accept Extensions via unique_ptr
This way we can remove them correctly and avoid leaks.

R=mstarzinger@chromium.org, ulan@chromium.org

Bug: v8:8725
Change-Id: I52cbbf34a94171aaeb581b55aecb25311465544d
Reviewed-on: https://chromium-review.googlesource.com/c/1446453
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59266}
2019-02-01 07:15:18 +00:00
Michael Lippautz
06193b0b79 [api] Move forward deprecations around Persistent handles
In future, weak handles will be considered as independent and MarkActive() will
not be supported anymore. Users should switch to TracedGlobal, when relying on
special cases for using handles with v8::EmbedderHeapTracer.

Bug: chromium:923361, v8:8562
Change-Id: Ic6e01a1ab59a25c5fb0aa2ebfb8ddb02e454d72d
Reviewed-on: https://chromium-review.googlesource.com/c/1443064
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59194}
2019-01-30 10:13:24 +00:00
Deepti Gandluri
4089299494 Add a contents based constructor to the SharedArrayBuffer API
The motivation of this change was originally to preserve is_growable
flag over PostMessage in d8. Adding a more general constructor that
uses SharedArrayBuffer::Contents.

Change-Id: Ib8f6c36d659e91f6cfb6487f56de34fa7e8841a9
Bug: v8:8564
Reviewed-on: https://chromium-review.googlesource.com/c/1383093
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: Ben Smith <binji@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59184}
2019-01-29 20:47:30 +00:00
Michael Lippautz
76c9368593 [api, global-handles] Add TracedGlobal
TracedGlobal integrates with the use case of EmbedderHeapTracer and replaces
regular weak Global or Persistent nodes for such cases. This allows to simplify
the case for regular weak handles in a sense that they follow regular weak
semantics (if the underlying object is otherwise unreachable the weak handle
will be reset).

TracedGlobal requires slightly different semantics in the sense that it can be
required to keep them alive on Scavenge garbage collections because there's a
transitive path that is only known when using the EmbedderHeapTracer.
TracedGlobal accomodates that use case.

TracedGlobal follows move semantics and can thus be used in regular std
containers without wrapping data structure.

The internal state uses 20% less memory and allows for only iterating those
nodes when necessary. The design trades the virtual call when iterating
interesting persistents in the GC prologue with calling out through the
EmbedderHeapTracer for each node which is also a virtual call. There is one less
iteration over the set of handles required though and the design is robust
against recursive GCs that mutate the embedder state during the prologue
callback.

Bug: chromium:923361
Change-Id: Idbacfbe4723cd12af9de21058a4792e51dc4df74
Reviewed-on: https://chromium-review.googlesource.com/c/1425523
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59183}
2019-01-29 20:15:39 +00:00