Commit graph

44 commits

Author SHA1 Message Date
turnidge@google.com 18a8d7fe4c Fixes bug where we would occasionally materialize a corrupted object.
On the slow path for a stack overflow check we manually spill the live
registers before our call to the runtime function.  We were updating
all uses of these spilled registers in the Environment object but this
was not enough - we also need to update any uses of these spilled
registers in MaterializeObjectInstrs which are hanging off of the
Environment.

This would fail when a deoptimization was triggered during a stack
overflow check and a materialized object happened to refer to
registers.

I've been chasing this for a while and I was able to get it to
reliably reproduce by using the --stacktrace_every=N and the
--stacktrace_filter flags, which were added for this purpose.

ALSO:

Set the top context to null on exceptions/errors.  This is needed for
the --verify-incoming-context flag.

Minor printing improvements.

R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35443 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-25 20:24:27 +00:00
johnmccutchan@google.com 3834c9a869 Support for multiple register values
- Adds a PairLocation type (Location is still a single word but now has two tags one for constants and one for pairs).
- New representations: kPairOfTagged & kPairOfUnboxedDouble.
- Register allocator uses second SSA index for Definitions that use two registers.
- Fix LiveRange shape for kWritableRegister inputs.
- Updated MergedMathInstr that returns a kPairOfTagged or kPairOfUnboxedDouble (depending on the merged math kind).
- A new instruction (ExtractNthOutput) for extracting a single register from an instruction that has a output register pair.

Open issues that need to be addressed in a follow up CL:

- Adjust PhiInstr and handling of PhiInstr in the register allocator to work with output pairs (once unboxed mints are in GPRs).

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34833 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-08 16:13:43 +00:00
johnmccutchan@google.com e255df56ed Refactor to support multiple outputs in location summary
R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34250 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-21 14:40:30 +00:00
fschneider@google.com 9031c80c88 Change == into an instance call to allow polymorphic inlining of ==.
In unoptimized code equality is now just another instance call.

The optimizer replaces it with a specialized implementation based on static
 type information and type feedback.

Many of the manual optimizations of == in the optimizer are now just handled
 by the generic inliner, plus polymorphic inlining of == calls is now possible.
This also eliminates the need for a lot of duplicated code in the backend.

I adapted the inlining heuristics to compensate for the slightly larger
inital flow graph size.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29800 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-04 11:32:52 +00:00
kmillikin@google.com de1519525c Reapply "Do not directly load smi constants larger than a 16 bit..."
Reapply "Do not directly load smi constants larger than a 16 bit payload on
ia32" with a bugfix.  The predicate Assembler::IsSafeSmi incorrectly
returned true for non-smis on non-ia32 platforms.

Original summary: Instead of emitting a large smi constant directly as an
immediate, xor the smi with a random 32-bit cookie at compile time, emit
code to move that into a register and then to xor the register with the
cookie.

Original codereview: https://codereview.chromium.org/48743002/

R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29533 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-30 11:38:39 +00:00
whesse@google.com 0729948569 Revert "Do not directly load smi constants larger than a 16 bit payload on ia32."
There is an assertion failure on debug VM tests.

BUG=
R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29458 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-29 16:49:42 +00:00
kmillikin@google.com adf6560e82 Do not directly load smi constants larger than a 16 bit payload on ia32.
Instead of emitting a large smi constant directly as an immediate, xor the
smi with a random 32-bit cookie at compile time, emit code to move that into
a register and then to xor the register with the cookie.

1. In unoptimized code constants are always loaded into a register in
   ConstantInstr::EmitNativeCode.  Change it to load safely.

2. In optimized code constants loaded into a register for use by an
   instruction are loaded by ParallelMoveResolver::EmitMove.  Change it to
   load safely.

3. In optimized code some instructions allow constants as inputs.  These are
   reflected with an input location of Location::RegisterOrConstant (or
   similar) or else Location::Constant.  For the former allocate a register
   if the constant is unsafe, and for the latter check for safety before
   allowing the constant input.

BUG=https://code.google.com/p/dart/issues/detail?id=1742
R=iposva@google.com, srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29439 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-29 12:19:12 +00:00
kmillikin@google.com 253fc69ecc Record a correct deoptimization environment for slow-path code.
Slow-path code is not marked as a call, so the deoptimization environment
built by the register allocator can contain unspilled registers.  However,
all registers are spilled before the call.  Compute the spill slot for all
registers and change the ones in the deoptimization environment to be
spilled.

BUG=https://code.google.com/p/dart/issues/detail?id=13995
R=fschneider@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29239 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-25 10:17:10 +00:00
jacobr@google.com 605b33c1bc fix cpp11 compile errors
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26387 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-20 20:24:11 +00:00
zra@google.com 351aaec2c3 Replaces Location::ToStackSlotAddress() with Location::ToStackSlotOffset()
This way, Location no longer mentions the architecture specific Address class.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25122 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-17 20:54:34 +00:00
regis@google.com 5eb7e3b03d Optimize functions containing try-catch on ARM.
R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24615 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-28 23:09:34 +00:00
regis@google.com 53347a3337 Remove stack_frame_<arch>.cc files.
The architecture specific information is in stack_frame_<arch>.h files.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22470 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-07 18:06:21 +00:00
regis@google.com 880af693cf Introduce architecture specific headers describing Dart stack frames.
The actual cleanup will follow in another cl.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22394 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-03 21:42:16 +00:00
vegorov@google.com 4d4a91ac04 Fix bug in ParallelMoveResolver::EmitSwap: implement swaps of FPU spill slots.
Remove representation from location. Presence of representation in location encoding was violating the invariant that unequal locations must be disjoint (where equality for locations is defined in terms of bitwise equality of their encoding). This could lead ParallelMoveResolver to treat XMM1 containing unboxed double as unequal location to XMM1 containing unboxed mint, which is obviously incorrect.

For similar reason eliminate kFloat32x4StackSlot and kUint32x4StackSlot distinction is eliminated and both are replaced with kQuadStackSlot. Register allocator now guarantees that no kQuadStackSlot occupies the same space as any other kDoubleStackSlot. This also shrinks optimized stack when only doubles are used (but might lead to a higher stack utilization when a mixture of doubles and quads is used).

Implement allocation of scratch Cpu and Xmm registers for ParallelMoveResolver. This also allows to remove push(eax)/pop(eax) pairs when resolving memory-memory cycles on ia32.

BUG=dart:9710

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21148 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-09 12:23:46 +00:00
johnmccutchan@google.com 3d4778e2c2 SIMD plumbing
Review URL: https://codereview.chromium.org//12871015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20287 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-20 20:29:00 +00:00
regis@google.com 7b5a610084 Make allocation of Dart parameters and local variables architecture independent.
Enable a couple more vm tests on ARM.
Fix function usage counter access on ARM.
Review URL: https://codereview.chromium.org//12776006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20048 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 21:33:03 +00:00
regis@google.com 912194a756 Fix vm code base so that it can be built for --arch=simarm (no snapshot yet).
Review URL: https://codereview.chromium.org//11956004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17246 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-18 00:34:20 +00:00
fschneider@google.com 87a3a4b479 Support immediate and memory operands for PushArgumentInstr in optimized code.
If a value is a constant or stored on the stack this change avoids loading it into a
new register before pushing it.
Review URL: https://codereview.chromium.org//11791051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16806 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-08 16:51:57 +00:00
fschneider@google.com 8aa175b9e6 Restrict immediate operands to smi where only smis are supported.
Re-enable redundant phi elimination.

Add x64 codegen templates and assembler instructions for immediate operands.

Fix x64 assembler for imull when using r8-r15.

Add x64 instruction for imulq(reg, imm).

Fix x64 disassembler printing of immediates.
Review URL: https://codereview.chromium.org//11362210

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14814 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-12 22:44:34 +00:00
vegorov@google.com 5f9ff89e0a Add support for WritableRegister policy in the register allocator.
Use it to eliminate push/pop on the fast path of the write barrier.

Tighten assertions in StoreIntoObject to ensure that value register is not equal to object register. Current code can't cope with that.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12193 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-11 12:50:52 +00:00
cshapiro@google.com da14bf70a7 Add attributions so printf like functions can have their arguments checked.
This change also corrects some misuses of format strings and format
arguments that discovered by the compiler checks.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11912 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-06 00:58:25 +00:00
kmillikin@google.com 0750c472dc Reapply "Remove classes Computation and BindInstr."
Reapply svn revision 11868 with a bugfix.

Original code review at http://codereview.chromium.org/10908091/

R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11890 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-05 17:04:49 +00:00
kmillikin@google.com 7e36720fa8 Revert "Remove classes Computation and BindInstr."
This reverts svn revision 11868.

TBR=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11869 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-05 11:20:14 +00:00
kmillikin@google.com bd84c7ee22 Remove classes Computation and BindInstr.
The former Computation classes are folded into the Instruction class
hierarchy.

R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11868 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-05 11:15:34 +00:00
fschneider@google.com 30a026f240 Support immediate operands for array bounds checks.
Review URL: https://chromiumcodereview.appspot.com//10916090

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11824 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-04 15:15:36 +00:00
vegorov@google.com a573d2dec8 Unbox phis that were proven to be of type Double.
Eliminate Boxing/Unboxing pairs.

Allow boxing, unboxing and double binary operations to participate in CSE.

Allow double comparisons to operate on unboxed inputs.

Support XMM registers and double spill slots in deoptimization.

Save XMM registers when calling to runtime from WriteBarrier stub.

R=srdjan@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11652 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-30 20:39:48 +00:00
vegorov@google.com 264c4f6d1a Add support for XMM registers in SSA code generation pipeline.
Split BinaryDoubleOp into several instructions that manipulate unboxed doubles.

R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11313 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-24 14:45:42 +00:00
vegorov@google.com 181be0165b Rename is_call to always_calls and contains_call to can_call.
R=kmillikin@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10735 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-15 14:26:39 +00:00
vegorov@google.com fe291bf0fa Implement basic support for deferred slow path code with calls that save and restore live registers.
Use it to avoid spilling over stack-checks.

R=kmillikin@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10639 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-14 12:47:42 +00:00
kmillikin@google.com 172ee045f3 Build and use stack maps in the SSA compiler.
Add a stack bitmap to the location summaries for calls that are GC
safepoints.  The bitmap covers the spill slots.  The register
allocator collects these bitmaps into a list and then marks live
pointer values during register allocation.  When emitting code for a
call, a heap-allocated stackmap is built.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10618 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-14 06:59:24 +00:00
vegorov@google.com abfb2bf67a Implement simple spill store elimination.
Values that are spilled somewhere during their life-time are spilled eagerly at their definiton.

Additionally improve liverange printing used for debugging purposes.

R=srdjan@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10155 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 08:45:49 +00:00
kmillikin@google.com 25ac913c69 Remove the default contains_call parameter on location summaries.
The plan is to use this parameter to make finer distinctions between
calls (e.g., safepoint vs. non-safepoint).  It's a bit safer to eliminate
the default.

R=vegorov@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10052 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-31 11:51:47 +00:00
vegorov@google.com c9e8d9594e Add support for fixed parameters in the register allocator.
This remove bailout for functions with non-zero number of non-fixed parameters and increases our coverage.

SpillSlot location was renamed into StackSlot location and now allows to address spill slots (positive stack index) and incoming parameters (negative stack index).

Environment was reordered to match order of values on the stack (previously it was inversed).

Correctly reserve spill slots in the prologue of the code. Previously register allocator was allocating spill slots, but generated code did not reserve any space for them on the stack so they might have been overwritten by calls.

Fix off by one in DeoptimizationStub::GenerateCode - we were reserving one slot too many.

Change --optimization-filter flag to use substring search instead of prefix comparison, this is much more useful when VM prefixes function name with a path to the file.

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9934 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-26 13:21:39 +00:00
vegorov@google.com 16e25206d1 New linear scan allocator.
Review URL: https://chromiumcodereview.appspot.com//10800037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9851 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-24 16:01:54 +00:00
vegorov@google.com d83a634324 Add spill slot locations.
Review URL: https://chromiumcodereview.appspot.com//10805053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9810 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-23 14:05:48 +00:00
srdjan@google.com 66d31c8b23 Fix crash during parallel moves. Made MoveOperands ZoneAlloacted. Non-const ValueObjects a fragile, since it is easy to modify a copy instead of the original. It is also dangereous to use pointers to ValueObjects that contain copy constructors.
Review URL: https://chromiumcodereview.appspot.com//10806047

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9790 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-20 21:16:06 +00:00
vegorov@google.com 1bd5a9b414 Skeleton of a linear scan register allocator.
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9563 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-11 18:52:17 +00:00
vegorov@google.com 1ae72fbd8b Change comparison-to-branch fusion to actually remove comparison from the graph.
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9556 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-11 17:41:54 +00:00
vegorov@google.com 959cf98b00 Implement a simple register allocator that tries to keep instruction results in registers.
Add --optimization-filter flag that allows to disbable optimizations for all function which do not match prefix. This allows to quickly localize problems with code generation.

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8811 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-18 18:04:22 +00:00
srdjan@google.com b4b68ef347 Move ReturnInstr to new scheme (x64 and ia32) and implement more code in new ia32 compiler.
Review URL: https://chromiumcodereview.appspot.com//10458050

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8166 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-31 17:24:23 +00:00
srdjan@google.com 742a716dc7 Fix a bug in ia32 shift left , implemented more inlined binary operations in x64.
Review URL: https://chromiumcodereview.appspot.com//10440082

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8119 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-30 17:35:20 +00:00
fschneider@google.com 7a212e5d27 Add support for temp locations and port Load-/StoreStaticField to use locations.
The temps are allocated like inputs (can be fixed register or not). Temp registers
are always distinct from all inputs and the output.
Review URL: https://chromiumcodereview.appspot.com//10443013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7961 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 20:14:53 +00:00
srdjan@google.com d67923100b CTX and TMP registers may not be allocated.
Review URL: https://chromiumcodereview.appspot.com//10399136

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7888 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-23 00:27:01 +00:00
vegorov@google.com 7f95f43a76 Introduce locations based code generation.
Instructions and computations switched to the new code generation scheme should implement two virtual functions:

- locs() should return pointer to a LocationSummary object, that specifies location constraints for the instruction/computation.

- EmitNativeCode() should emit instructions/computations native code using locations provided through LocationSummary object attached to the instruction.

For converted functions instruction pattern should be removed from the FlowGraphCompiler visitor. It will not be used as long as instruction/computation returns non-NULL from locs().

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7818 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-21 19:51:17 +00:00