Commit Graph

184 Commits

Author SHA1 Message Date
Ryan Macnak af251ddfec [vm] Prefer stack bounds from the system thread library for overflow checks.
Before this change, we would assume all stacks have the size the VM specifies for threads it creates, but this won't be accurate for the initial thread or threads created by the embedder.

Change-Id: I6605a88d6666a6f9d47fbe047d3fdd02aa22c80a
Reviewed-on: https://dart-review.googlesource.com/10209
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-11 19:35:44 +00:00
Vyacheslav Egorov 8a179fb953 [VM, Compiler] Move compiler to a separate folder.
New folder structure (nested under vm/):

- compiler/
-   jit/         - JIT specific code
-   aot/         - AOT specific code
-   backend/     - all middle-end and back-end code (IL, flow graph)
-   assembler/   - assemblers and disassemblers
-   frontend/    - front ends (AST -> IL, Kernel -> IL)

compiler/README.md would be the documentation root for the compiler
pipeline

Bug: https://github.com/dart-lang/sdk/issues/30575
Change-Id: I2dfd9688793bff737f7632ddc77fca766875ce36
Reviewed-on: https://dart-review.googlesource.com/2940
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-04 15:15:18 +00:00
Alexander Markov 5aead50245 [vm] Implement more efficient CAS in simarm/simarm64 modes, v.2
This CL includes db26c89347 (patch set #1)
with fix (patch set #2):
* Include simulator.h explicitly where it is required as it is no
  longer included implicitly through other header files.

Original review: https://codereview.chromium.org/2995803002/

When running on the simulator for arm/arm64, compare-and-swap operations
used in VM were synchronized with simulator using mutex.
It heavily impacts performance when doing parallel marking due to high
contention (see #30317).
This synchronization was implemented in order to make simulated
LDREX/STREX instructions aware of CAS performed in VM.

This CL drops this synchronization between VM and simulator:
CAS operations in VM become regular, and simulator remembers value loaded
with load-exclusive and performs CAS when doing store-exclusive to catch
any concurrent modifications.

Speeds up gen_snapshot of flutter benchmark complex_layout from 9.2s
to 8.0s on my MacBook.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2999853002 .
2017-08-14 11:10:29 -07:00
Alexander Markov 0ffe7148b8 Revert "[vm] Implement more efficient CAS in simarm/simarm64 modes"
This reverts commit db26c89347.

Review-Url: https://codereview.chromium.org/3000803003 .
2017-08-11 17:51:50 -07:00
Alexander Markov db26c89347 [vm] Implement more efficient CAS in simarm/simarm64 modes
When running on the simulator for arm/arm64, compare-and-swap operations
used in VM were synchronized with simulator using mutex.
It heavily impacts performance when doing parallel marking due to high
contention (see #30317).
This synchronization was implemented in order to make simulated
LDREX/STREX instructions aware of CAS performed in VM.

This CL drops this synchronization between VM and simulator:
CAS operations in VM become regular, and simulator remembers value loaded
with load-exclusive and performs CAS when doing store-exclusive to catch
any concurrent modifications.

Speeds up gen_snapshot of flutter benchmark complex_layout from 9.2s
to 8.0s on my MacBook.

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2995803002 .
2017-08-11 17:36:10 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Martin Kustermann ac8d2056a3 Fix asserts in StackFrameIterator which were effectively disabled
The assertions which tried to assert that we only use
StackFrameIterator to walk frames of the current thread was incorrect.
We already have cases where other threads will walk the stack of the
mutator thread, see below for an example where this can happen.

Thread::VisitObjectPointers was incorrectly passing Thread::Current() to
the StackFrameIterator instead of 'this'.  (Code in thread_registry.cc will
loop over a number of threads and calls VisitObjectPointers on them)

  Mutator thread:

    0  pthread_cond_wait@@GLIBC_2.3.2
    1  dart::Monitor::WaitMicros
    2  dart::Monitor::Wait
    3  dart::MonitorLocker::Wait
    4  dart::ThreadBarrier::Sync
    5  dart::GCMarker::MarkObjects
    6  dart::PageSpace::MarkSweep
    7  dart::Heap::CollectOldSpaceGarbage
    8  dart::Heap::CollectNewSpaceGarbage
    9  dart::Heap::CollectGarbage
    10 dart::DN_HelperObject_<native>
    11 dart::BootstrapNatives::<native>
    <dart frames>

  MarkTask thread:

    1  dart::EntryFrame::VisitObjectPointers
    2  dart::Thread::VisitObjectPointers          <---- Walks mutator thread stack
    3  dart::ThreadRegistry::VisitObjectPointers  <---- Iterates over a number of threads
    4  dart::Isolate::VisitStackPointers
    5  dart::Isolate::VisitObjectPointers
    6  dart::GCMarker::IterateRoots
    7  dart::MarkTask::Run
    8  dart::ThreadPool::Worker::Loop
    9  dart::ThreadPool::Worker::Main
    10 dart::ThreadStart

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2845053003 .
2017-05-03 10:27:01 +02:00
Ryan Macnak 9f2668c998 Set TARGET_OS_* from GN, falling back to HOST_OS_*.
Use TARGET_OS_* instead of HOST_OS_* to decide on the assembly variant to use. Allows, say, a gen_snapshot compiled for a Mac to target Android when generating AOT as assembly.

R=fschneider@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2757783003 .
2017-03-20 14:48:28 -07:00
Todd Turnidge 2d22e85cf0 Revert "Revert "JumpToFrame refactor"" + Fix
This reverts commit 1cdb3d2155.

I have also added in a fix for the lazy-deopt in exception handler case.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2506503002 .
2016-11-21 08:49:18 -08:00
Todd Turnidge 1cdb3d2155 Revert "JumpToFrame refactor"
This reverts commit 5ed13d3298.

BUG=

Review URL: https://codereview.chromium.org/2503623003 .
2016-11-14 15:57:01 -08:00
Todd Turnidge 5ed13d3298 JumpToFrame refactor
- Refactor the JumpToExceptionHandle code so that it is now built from
  two pieces: JumpToFrame and RunExceptionHandler.

- Refactor the Simulator::Longjmp() code so that it is no longer
  exception-specific.  Instead it uses the RunExceptionHandler stub.

This makes it so that the JumpToFrame stub and Simulator::JumpToFrame
have the same semantics.  This will make it easier to land the Rewind
changes I am working on.

There are some oddities for dbc.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2503653002 .
2016-11-14 14:38:21 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Ryan Macnak e3420eab29 Revert "Pass new pool pointer to the JumpToException stub instead of reloading in through the frame's Code object."
This reverts commit 3413e052b3.

Review URL: https://codereview.chromium.org/2374173002 .
2016-09-28 13:00:00 -07:00
Ryan Macnak 3413e052b3 Pass new pool pointer to the JumpToException stub instead of reloading in through the frame's Code object.
This is prep work for lazy deopt without code patching.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2376843002 .
2016-09-28 10:15:09 -07:00
Florian Schneider 7ca3da1a3a Fix lazy deoptimization in the presence of exceptions
Catch block entries need to be considered when doing lazy deoptimization.

In addition to the return, also patch all catch entry blocks in a function scheduled for lazy deoptimization.

Also, move restoring the pool pointer to the jump-to-handler stub to simplify patching the catch entry.

BUG=#27419
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2357343003 .
2016-09-26 16:24:23 -07:00
Ryan Macnak 7ff2dd4117 Optimize AOT's switchable calls for the monomorphic case.
The call sequence is very similar to a classic IC call, except the guarded class and the target are loaded indirectly from the constant pool instead of as immediates. In the monomorphic case, we call directly to the expected target with a class check in the callee. In the unlinked, polymorphic and megamorphic cases, we call a stub; these case are now call-through instead of call-and-return.

Every code, except stubs involved in switchable calls, includes the class check sequence at the beginning. So we now distinguish between a checked and an unchecked entry point. Generated code except the switchable call continues to use the unchecked entry point.

PC offsets are calculated relative to the beginning of the instruction stream, rather than either entry point.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2226893002 .
2016-08-12 11:18:35 -07:00
Ryan Macnak a0df7275d6 Use log prints for simulation tracing and fix --disassemble-stubs.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2229553005 .
2016-08-09 14:03:29 -07:00
Ryan Macnak 85cdc0eac2 Don't assume we want the iOS ABI if running simarm on Mac and the EABI otherwise.
Allow controlling the target ABI by defining TARGET_ABI_IOS or TARGET_ABI_EABI.  If neither is defined, default to the previous behavior.

Make Linux, Mac, Android and iOS agree on the value of PreferredCodeAlignment for all architectures.

BUG=http://dartbug.com/26464
R=zra@google.com

Review URL: https://codereview.chromium.org/1982613003 .
2016-05-17 15:03:54 -07:00
Vyacheslav Egorov ee0f608ce4 Dart Byte Code interpreter.
This version is Clang/GCC only and does not support Windows because it uses computed goto's.

Only unoptimized mode is supported.

Architecture is described in constants_dbc.h and stack_frame_dbc.h.

R=fschneider@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1858283002 .
2016-04-18 23:02:01 +02:00
Siva Annamalai 56e888d4cd - Move
stack_limit_,
   stack_overflow_flags_,
   saved_stack_limit_,
   stack_overflow_count_ and
   other interrupts mask fields from Isolate structure to Thread structure

- Change the stack overflow check in the prolog to load the stack limit
  from the THR register, this removes the back to back dependent loads to
  load the stack limit from the Isolate structure

R=johnmccutchan@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1812753002 .
2016-03-17 12:57:36 -07:00
Zachary Anderson 88ad41c959 Fix Android build warnings
R=regis@google.com

Review URL: https://codereview.chromium.org/1809743002 .
2016-03-16 11:17:53 -07:00
Regis Crelier 3ffe9922b7 Simplify various name flavors in VM.
R=asiva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1723733002 .
2016-02-25 11:21:27 -08:00
Ryan Macnak c5f1818940 Fix product build for 32-bit architectures, simulators and ARM64.
(That's everything but X64.)

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1682113002 .
2016-02-09 11:25:44 -08:00
John McCutchan d77d376124 Replace intptr_t with TokenDescriptor
- Use TokenDescriptor instead of intptr_t for all token positions.
- Use TokenDescriptor in raw_object instead of int32_t.
- TokenDescriptor is a POD with an int32_t (this shrinks the size of AST and IR nodes by 32-bits on 64-bit architectures).

There are some cleanups I plan on doing as a follow up CL:

- Replace TokenDescriptor::value() with TokenDescriptor::TokenPos()

R=iposva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1644793002 .
2016-02-02 10:15:44 -08:00
Ryan Macnak 87eae28239 Fix simarm and simmips builds on Mac.
Broken by a7ebeb00fb.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1574393002 .
2016-01-12 12:47:26 -08:00
Siva Annamalai a7ebeb00fb Add a CompareAndSwapUint32 variant to AtomicOperations so that it is possible to a CAS of a 32 bit value.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1562253002 .
2016-01-06 17:08:31 -08:00
Siva Annamalai 9e19d236ca - Add an OSThread structure which is the generic TLS structure for all C++
fields in a thread (i.e fields that are not Dart VM related)
- Split the Thread structure to be a pure Dart per thread structure and add
  a pointer to os_thread which points to the OSThread structure
- Change Schedule/UnSchedule to set the Dart Thread structure as the TLS of
  the thread when it is inside the Dart world and reset the TLS back to the
  OSThread strcuture when is exits the Dart World.
- Moved the stack_base and few stack size related functions to OSThread from Isolate

R=johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1439483003 .
2015-11-19 13:45:10 -08:00
Ryan Macnak c315da5a06 ARM: Don't generate memory instructions with writeback where the data and address registers are the same.
BUG=http://dartbug.com/24855
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1434323003 .
2015-11-13 12:13:55 -08:00
Ryan Macnak d422888b46 Use the iOS ABI when running SIMARM on Mac or targeting iOS.
Linux / iOS
R7   preserved / FP
R9   preserved / volatile
R11  FP / preserved

BUG=http://dartbug.com/24683
R=zra@google.com

Review URL: https://codereview.chromium.org/1421253004 .
2015-10-27 14:36:38 -07:00
Srdjan Mitrovic 8e14e2b459 Fix builds
BUG=

Review URL: https://codereview.chromium.org/1414343002 .
2015-10-20 11:20:22 -07:00
Srdjan Mitrovic dc2d81b636 Move vm_tags from isolate to thread, since we may have multiple threads in same isolate (GC, background compilation)
BUG=
R=johnmccutchan@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1387643002 .
2015-10-05 12:50:17 -07:00
Ryan Macnak 8ebb9f9b39 Track which entries in the ObjectPool are native entries, and reset them when loading a precompiled snapshot.
R=fschneider@google.com

Review URL: https://codereview.chromium.org//1316673005 .
2015-09-10 15:41:37 -07:00
Daniel Andersson 32046b2eb8 Migrate stack resource unwinding to Thread.
Also remove some uses of deprecated StackResource constructor.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1261873005 .
2015-07-31 12:57:19 -07:00
Ivan Posva 8f1506e817 - Determine whether the simulator is being used in globals.h
- Make sure to switch on HOST_ARCH_ and on USING_SIMULATOR
  where appropriate.
- Avoid allocating in new generation when running in the VM isolate.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1156053006
2015-05-29 14:35:29 -07:00
Daniel Andersson 6542a451c3 Refactor Isolate -> Thread in NativeArguments and exception handler jump.
Further reduces the one-to-one assumption about isolates and threads: native entries now ask the thread for its isolate, rather than the other way around.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1156143003
2015-05-26 16:49:51 -07:00
regis@google.com d5bace63ad Support profiling of simulated Dart code on mips, arm, and arm64.
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45430 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-27 19:55:53 +00:00
regis@google.com 2e2bcf6149 Use a breakpoint instruction for a stop message on arm instead of
a svc instruction (or hlt instruction on arm64).
The instructions svc and hlt are used in conjunction with a simulator only.
At least, gdb now stops on armv5te when hitting a stop message (no prompt).
Add support for printing stop message in disassembly on mips and arm64.
Clean up various bkpt codes on arm (now similar to arm64 and mips).

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45363 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-22 20:45:52 +00:00
zra@google.com 86bfd7cb30 Adds a simarmv5te build and test target.
Also:
- Removes command line flags to choose simulated arm version.
  I think we should use build targets instead, like in this change,
  to make building and testing more obvious.
- Skips pkg tests on all simulators.

R=regis@google.com, ricow@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45181 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 20:44:43 +00:00
regis@google.com 8a0194b846 Fix mint shifting by zero on MIPS (issue 23117).
Add regression test.
Restore formatting space dropped by mistake in simulator tracing output.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45042 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-09 22:50:25 +00:00
zra@google.com 9eaea2e779 Fixes ARM instruction version checking.
Emulates umaal on ARMv5TE.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44940 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-07 17:36:46 +00:00
zra@google.com b253b7c2ba A few fixes for ARMv5TE.
This CL:
- Adds SupportsHardwareDivision() to FlowGraphCompiler.
  In FlowGraphOptimizer, if SupportsHardwareDivision()
  is false, Smi and Mint division operations are not
  inlined.
- Reduces the supported addressing modes for ldrd, strd.
  For ARMv6 and up, the address only needs to be 4-byte
  aligned, for ARMv5TE and below the address must be
  8-byte aligned. So, on ARMv5TE, we can split these
  each into two instructions, which is easier to do if
  the addressing modes are restricted to base + offset,
  which is all we were using anyway.
- Uses the smull instruction on ARMv5TE and ARMv6. I don't
  remember why it was disabled, and the docs say
  it is supported. Verified working on ARMv5TE hardware.
- Fixes a bug in OSR frame entry caused by the
  difference between the PC read offset in store vs.
  other instructions.
- Fixes assembler tests that have a float return for
  targets without vfp.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44788 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-30 20:46:52 +00:00
koda@google.com b1634f7c30 Isolate -> Thread for tracking owner of mutex and simulator's exclusive access.
Prepares for multiple threads referencing the same isolate (in particular, the mutator and sweeper).

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44762 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-27 20:33:36 +00:00
koda@google.com c1008f15c0 Save top StackResource in entry frame.
This avoids relying on stack address order, which enables us to benefit from AddressSanitizer's detect_stack_use_after_return feature.

R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43927 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-20 20:46:31 +00:00
koda@google.com 4c74036e9b To satisfy ASAN, use stub instead of & operator to get C++ stack pointer.
Because of initialization order, this requires slightly different paths for VM isolate and others.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43865 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-19 04:58:08 +00:00
koda@google.com 554f25b53c Verify/document assumption about stack resource addresses.
We assume that addresses of stack resources refer to the actual stack and are ordered accordingly.
Using the AddressSanitizer with detect_stack_use_after_return will break this assumption.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43858 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-18 23:21:32 +00:00
regis@google.com d50fe1db24 Make instruction counter in simulators 64-bit (issue 22302).
This requires supporting uint64_t flag values.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43660 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 17:41:01 +00:00
koda@google.com 253de5e60a Fix race condition in Redirection global list using CAS.
Note that a simple Mutex cannot be used, since the profiler may interrupt the thread at any point, and also walks this list.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43557 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-06 15:50:08 +00:00
fschneider@google.com dd824bd017 Store pc offset instead of absolute pc in the pc descriptors.
This saves space on 64-bit platforms as the offset is stored
as a uint32_t compared to a pointer-size absolute address.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43100 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 12:30:11 +00:00
koda@google.com c7e9e048ed Rename Thread -> OSThread.
It's a collection of static utility methods for primitive operations on OS threads.

Make room in the namespace for upcoming class that will represent all the complex state of a VM thread.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42895 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-15 02:30:07 +00:00
srdjan@google.com e86aeecc72 Fix builds on Mac: icount_ is intptr_t.
Review URL: https://codereview.chromium.org//827453003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42565 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-24 01:07:17 +00:00