OSDN Git Service

android-x86/art.git
9 years agoFix thread priorities for unstarted threads.
Narayan Kamath [Tue, 7 Oct 2014 11:51:26 +0000 (12:51 +0100)]
Fix thread priorities for unstarted threads.

Calls to Thread.setPriority for unstarted threads now behave
similar to dalvik. Note that there's still some inconsistent
behaviour carried over from dalvik.

- high priority threads from bg_non_interactive processes are
  not always moved to the SP_FOREGROUND cgroup.
- we do not attempt to adjust the cgroup of a native thread
  that's attaching.

Note that on android, the system_server will change the
cgroups for all running threads in a process when it moves
into the foreground and background. It's by design that
threads in a background process can request to be moved
to the foreground by setting a higher priority.

bug: 17893086

Change-Id: I1662982b1c7b3ac509698e2e12c9768d082c8053

9 years agoART: Add miranda checking
Andreas Gampe [Sat, 1 Nov 2014 01:12:30 +0000 (18:12 -0700)]
ART: Add miranda checking

Add a test for resolution of miranda methods across dex-files. See
CL 112688 and b/18193682 for the code change.

Fix the test script to support no-verify again.

Weaken the dex cache check to a check whether the found method is a
miranda method. This will penalize miranda methods, as they will
always have to be resolved by name, but does not require the multi-step
load of the method's dex cache.

Bug: 18193682

(cherry picked from commit 2b0fa5ba4a8f07ee243452003bf93418d30e9448)

Change-Id: I1dae2a9ec0985dc8625acd7dd5686a5d3cdc8888

9 years agoMerge "Check null this pointer for direct methods in FindMethodFast." into lmp-mr1-dev
Jeff Hao [Mon, 3 Nov 2014 19:18:42 +0000 (19:18 +0000)]
Merge "Check null this pointer for direct methods in FindMethodFast." into lmp-mr1-dev

9 years agoCheck null this pointer for direct methods in FindMethodFast.
Jeff Hao [Thu, 30 Oct 2014 00:24:25 +0000 (17:24 -0700)]
Check null this pointer for direct methods in FindMethodFast.

Also adds regression test 122-secondarydex.

Bug: 18150997
Change-Id: If3ddc67b84ccbf3b47c78854178c0a24952c5824

9 years agoMerge "Add image strings to intern table" into lmp-mr1-dev
Mathieu Chartier [Mon, 3 Nov 2014 18:07:18 +0000 (18:07 +0000)]
Merge "Add image strings to intern table" into lmp-mr1-dev

9 years agoAdd image strings to intern table
Mathieu Chartier [Fri, 31 Oct 2014 18:49:27 +0000 (11:49 -0700)]
Add image strings to intern table

When we create the runtime, we now add the image strings to the
intern table if we are the zygote. This caused some memory bloat,
so I added an extra unordered set to the intern table.

There is now two unordered sets (hash talbe). One for pre-zygote
interns and one for post-zygote interns. This helps since the
pre-zygote hash table doesn't get dirtied. Even with adding
the image strings, we get total memory savings of around 5-7 MB
native PSS after device boot.

FB launch Before:
2.20% art::DexFile::FindStringId(char const*) const
TotalTime: 2069
TotalTime: 1985
TotalTime: 2088
TotalTime: 2003
TotalTime: 2034
TotalTime: 2049
After boot native PSS: 175585 kB: Native

After:
0.27% art::DexFile::FindStringId(char const*) const
TotalTime: 1682
TotalTime: 1756
TotalTime: 1825
TotalTime: 1751
TotalTime: 1666
TotalTime: 1813
After boot native PSS: 167089 kB: Native

Bug: 18054905
Bug: 16828525
Bug: 17808975

Change-Id: Ie367f3222f8c4db409ec49c3845276908b51e9c9

9 years agoam 64d79730: am 9a783d6a: Fix FindDeclaredVirtualMethod(DexCache...) for miranda...
Brian Carlstrom [Sat, 1 Nov 2014 14:08:28 +0000 (14:08 +0000)]
am 64d79730: am 9a783d6a: Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods

* commit '64d79730c33777a62e108942909773e5e782ece3':
  Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods

9 years agoMerge "ART: Discard generated image in a low-memory environment" into lmp-mr1-dev
Andreas Gampe [Sat, 1 Nov 2014 00:32:21 +0000 (00:32 +0000)]
Merge "ART: Discard generated image in a low-memory environment" into lmp-mr1-dev

9 years agoART: Discard generated image in a low-memory environment
Andreas Gampe [Fri, 31 Oct 2014 23:45:19 +0000 (16:45 -0700)]
ART: Discard generated image in a low-memory environment

In case the available memory after image generation is low,
discard the image and continue in interpreted mode to mitigate
low-mem issues.

Bug: 17975190
Change-Id: I67a0f9c32a6c1f1a7ec659e90b1fec834a92d323

9 years agoart: Fix classlinker and nopatchoat test for PIC case
Igor Murashkin [Thu, 30 Oct 2014 02:45:42 +0000 (19:45 -0700)]
art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

(cherry-picked from AOSP master
230faa7c44ec1986d5fa93d205eb23cb8024e333)

Bug: 18035729
Change-Id: I4eb184d22616230a7b8f0dd514d3416d0976b07e

9 years agoART: Add support for patching and loading OAT files compiled with PIC
Igor Murashkin [Wed, 22 Oct 2014 18:37:02 +0000 (11:37 -0700)]
ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

(cherry-picked from AOSP master
46774767fcf7780d1455e755729198648d08742e)

Conflicts (from aosp master):
compiler/image_test.cc
compiler/image_writer.cc
compiler/image_writer.h
compiler/oat_test.cc
dex2oat/dex2oat.cc
oatdump/oatdump.cc
runtime/elf_file.cc
runtime/elf_file.h
runtime/elf_file_impl.h
runtime/oat_file.cc
runtime/oat_file.h

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62

9 years agoART: Add pic flag to oat header store
Andreas Gampe [Thu, 23 Oct 2014 18:37:40 +0000 (11:37 -0700)]
ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

(cherry-picked from AOSP master
7ba649636c4475c3992fa15a57acd2546d69ff38)

Bug: 18035729
Signed-off-by: Igor Murashkin <iam@google.com>
Change-Id: Ie1f1ef37125386a968228033d1e2bec565315510

9 years agodex2oat: Add a --compile-pic option
Igor Murashkin [Fri, 17 Oct 2014 01:36:16 +0000 (18:36 -0700)]
dex2oat: Add a --compile-pic option

(cherry-picked from AOSP master
83c5612e69fa05610baf4f4d237fe0995a79cde5)

Bug: 18035729
Change-Id: I80e03613e3b6ac079bcbc7e068bbaae760c364c9

9 years agoam 9a783d6a: Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods
Brian Carlstrom [Fri, 31 Oct 2014 14:33:51 +0000 (14:33 +0000)]
am 9a783d6a: Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods

* commit '9a783d6a0cb437fc0d9ffcc84502912f3d1cb73b':
  Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods

9 years agoFix FindDeclaredVirtualMethod(DexCache...) for miranda methods
Brian Carlstrom [Fri, 31 Oct 2014 07:01:54 +0000 (00:01 -0700)]
Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods

If a class in classes.dex implements an interface from classes2.dex,
the miranda method will be in the dex cache for classes2.dex, but
pointed to by the virtual methods of the class in the dex caches for
classes.dex.

Therefore the fast path for DexCache::ResolveMethod that searches via
class and superclass virtual methods should ensure that any method
matching on dex method_idx should be from the same dex cache as the
class itself, which is not the case for miranda methods.

Bug: 18193682
Change-Id: I10da4f5472e929b3dc0be58051a726a4bc14e438

9 years agoMerge "Add hash table to link virtual methods" into lmp-mr1-dev
Mathieu Chartier [Thu, 30 Oct 2014 22:19:51 +0000 (22:19 +0000)]
Merge "Add hash table to link virtual methods" into lmp-mr1-dev

9 years agoAdd hash table to link virtual methods
Mathieu Chartier [Wed, 29 Oct 2014 01:23:02 +0000 (18:23 -0700)]
Add hash table to link virtual methods

Added a hash table for turning the O(m*n) lookup average case to
O(m+n) average case. There is probably still some room for improvement.

Before:
WaitTime: 2121
WaitTime: 2051
WaitTime: 2134
WaitTime: 2104
WaitTime: 2237
WaitTime: 2391
4.99% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod)
1.65% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

After:
WaitTime: 2038
WaitTime: 1965
WaitTime: 1979
WaitTime: 1976
WaitTime: 1957
WaitTime: 2004
0.46% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod*)
1.39% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

Bug: 18054905
Bug: 16828525

Change-Id: If847afb7194daa05ace38d15862e4b871dfffae1

9 years agoMerge "ART: Do not abort on most verifier failures" into lmp-mr1-dev
Andreas Gampe [Thu, 30 Oct 2014 16:59:15 +0000 (16:59 +0000)]
Merge "ART: Do not abort on most verifier failures" into lmp-mr1-dev

9 years agoMerge "Fix deoptimization bugs" into lmp-mr1-dev
Sebastien Hertz [Thu, 30 Oct 2014 10:14:44 +0000 (10:14 +0000)]
Merge "Fix deoptimization bugs" into lmp-mr1-dev

9 years agoam 2759810f: am 7dd72618: Work around relocated boot.oat corruption
Brian Carlstrom [Wed, 29 Oct 2014 18:51:44 +0000 (18:51 +0000)]
am 2759810f: am 7dd72618: Work around relocated boot.oat corruption

* commit '2759810fc4dab86c52f23c8603e5c7479182ae21':
  Work around relocated boot.oat corruption

9 years agoam f4e60fb4: am efb9f850: ART: Fix ImageSpace error message.
Andreas Gampe [Wed, 29 Oct 2014 18:50:54 +0000 (18:50 +0000)]
am f4e60fb4: am efb9f850: ART: Fix ImageSpace error message.

* commit 'f4e60fb49f96aeb13a58523b7f9f9e91ab4b533c':
  ART: Fix ImageSpace error message.

9 years agoam d7c581cc: am a6b2affa: Remove boot.art/boot.oat on failure to create
Brian Carlstrom [Wed, 29 Oct 2014 18:49:10 +0000 (18:49 +0000)]
am d7c581cc: am a6b2affa: Remove boot.art/boot.oat on failure to create

* commit 'd7c581cc076a03da2b00a9a3ceaeb5d04ec815df':
  Remove boot.art/boot.oat on failure to create

9 years agoFix deoptimization bugs
Sebastien Hertz [Wed, 29 Oct 2014 11:21:55 +0000 (12:21 +0100)]
Fix deoptimization bugs

Only concerns long and double variables which use a register pair.

Bug: 18167243

(partial cherry-pick of commit 07140838a3ee44a6056cacdc78f2930e019107da)

Change-Id: Ibbbd9b1ed576a1502ca0025a3e27176014ed2548

9 years agoMerge "Make ObjectRegistry::InternalAdd GC safe" into lmp-mr1-dev
Sebastien Hertz [Wed, 29 Oct 2014 08:30:53 +0000 (08:30 +0000)]
Merge "Make ObjectRegistry::InternalAdd GC safe" into lmp-mr1-dev

9 years agoam 7dd72618: Work around relocated boot.oat corruption
Brian Carlstrom [Wed, 29 Oct 2014 01:33:42 +0000 (01:33 +0000)]
am 7dd72618: Work around relocated boot.oat corruption

* commit '7dd7261845258b7c29b588829c80164b878f4424':
  Work around relocated boot.oat corruption

9 years agoART: Do not abort on most verifier failures
Andreas Gampe [Tue, 28 Oct 2014 03:08:46 +0000 (20:08 -0700)]
ART: Do not abort on most verifier failures

Changes hard aborts to hard verifier failures, which rejects a
class instead of killing the process.

Bug: 17625962
Change-Id: Iba8e15676e13ea6dcd6e1e5d0484031d9ab52ae9

9 years agoTidy MethodProtoHelper.
Ian Rogers [Tue, 28 Oct 2014 16:34:57 +0000 (09:34 -0700)]
Tidy MethodProtoHelper.

Move to place of only use, class_linker.cc. Be lazy in computing the name.

Before:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

After:
WaitTime: 2749
WaitTime: 2786
WaitTime: 2852
WaitTime: 2856
WaitTime: 2703
WaitTime: 2784

Bug: 18054905
Bug: 16828525

(cherry picked from commit 03b6eafba8ace9a9c4d5ee9c47723d1910ccd7a8)

Change-Id: I1438efbda58369ddd0ac36eda8a5a0a6c6fdff77

9 years agoWork around relocated boot.oat corruption
Brian Carlstrom [Tue, 28 Oct 2014 22:53:43 +0000 (15:53 -0700)]
Work around relocated boot.oat corruption

Bug: 18143314
Change-Id: Ibecade061d6c887bde2f8a085ed7dede3345125a

9 years agoMerge "Fill resolved static fields during class initialization" into lmp-mr1-dev
Mathieu Chartier [Tue, 28 Oct 2014 22:09:35 +0000 (22:09 +0000)]
Merge "Fill resolved static fields during class initialization" into lmp-mr1-dev

9 years agoFill resolved static fields during class initialization
Mathieu Chartier [Tue, 28 Oct 2014 20:57:04 +0000 (13:57 -0700)]
Fill resolved static fields during class initialization

Previously everytime we resolved static fields we linear searched
the class to find the field with the specified field id. Now we
eagerly set these fields in the dex cache when we initialize classes.

FB launch timings before:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

Timings after:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

Perf before:
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
After:
0.00% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)

Bug: 18054905
Bug: 16828525

Change-Id: I33255f85d10c29cae085584880196c45ac0ea230

9 years agoam efb9f850: ART: Fix ImageSpace error message.
Andreas Gampe [Tue, 28 Oct 2014 21:37:02 +0000 (21:37 +0000)]
am efb9f850: ART: Fix ImageSpace error message.

* commit 'efb9f850292a2ea5aae4ab56556c9ab25b308a96':
  ART: Fix ImageSpace error message.

9 years agoART: Fix ImageSpace error message.
Andreas Gampe [Sat, 25 Oct 2014 04:55:52 +0000 (21:55 -0700)]
ART: Fix ImageSpace error message.

Use *error_msg instead of error_msg.

(cherry picked from commit 50f2e9a6b935ba1c456a687e5f0822d9356d71e5)

Bug: 18143314
Change-Id: I62f6aeda142235eb1a412a4c1ae1104b813e6967

9 years agoMerge "[native bridge] Make sure we always unload the native bridge" into lmp-mr1-dev
Calin Juravle [Tue, 28 Oct 2014 17:17:10 +0000 (17:17 +0000)]
Merge "[native bridge] Make sure we always unload the native bridge" into lmp-mr1-dev

9 years agoMerge "[native bridge] Add test to verify code_cache existance." into lmp-mr1-dev
Calin Juravle [Tue, 28 Oct 2014 17:16:46 +0000 (17:16 +0000)]
Merge "[native bridge] Add test to verify code_cache existance." into lmp-mr1-dev

9 years agoMake ObjectRegistry::InternalAdd GC safe
Sebastien Hertz [Thu, 23 Oct 2014 13:39:33 +0000 (15:39 +0200)]
Make ObjectRegistry::InternalAdd GC safe

Because a call to IdentityHashCode may cause GC, the object pointer
may become invalid (if the object has been moved) on next uses. We
now access the object through a Handle to be GC safe.

Also remove unused methods.

Bug: 18098424

(cherry picked from commit e2d628b5b0a1b9c29c173f3cbad3ef6cb6c24d2d)

Change-Id: I4fdff54053aa947765a39adf67345b08816387e5

9 years agoMerge "Fixed debugger for threads attached from JNI" into lmp-mr1-dev
Sebastien Hertz [Tue, 28 Oct 2014 08:24:22 +0000 (08:24 +0000)]
Merge "Fixed debugger for threads attached from JNI" into lmp-mr1-dev

9 years agoMerge "Fix JDWP Virtualmachine.Resume command" into lmp-mr1-dev
Sebastien Hertz [Tue, 28 Oct 2014 08:23:48 +0000 (08:23 +0000)]
Merge "Fix JDWP Virtualmachine.Resume command" into lmp-mr1-dev

9 years agoam a6b2affa: Remove boot.art/boot.oat on failure to create
Brian Carlstrom [Tue, 28 Oct 2014 06:21:37 +0000 (06:21 +0000)]
am a6b2affa: Remove boot.art/boot.oat on failure to create

* commit 'a6b2affaf99e03f938f6f26e42606488d43f2efe':
  Remove boot.art/boot.oat on failure to create

9 years agoFix 64 bit build
Mathieu Chartier [Tue, 28 Oct 2014 00:30:20 +0000 (17:30 -0700)]
Fix 64 bit build

Buggy compiler.

Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064

9 years agoRemove boot.art/boot.oat on failure to create
Brian Carlstrom [Mon, 27 Oct 2014 23:27:06 +0000 (16:27 -0700)]
Remove boot.art/boot.oat on failure to create

Bug: 18143314
Change-Id: I5f4733ed7f359158a2bda58ff4f228ba60e2f493

9 years agoMerge "Optimize method linking" into lmp-mr1-dev
Mathieu Chartier [Mon, 27 Oct 2014 23:04:22 +0000 (23:04 +0000)]
Merge "Optimize method linking" into lmp-mr1-dev

9 years agoOptimize method linking
Mathieu Chartier [Thu, 23 Oct 2014 23:48:06 +0000 (16:48 -0700)]
Optimize method linking

Added more inlining, removed imt array allocation and replaced it
with a handle scope. Removed some un-necessary handle scopes.

Added logic to base interface method tables from the superclass so
that we dont need to reconstruct for every interface (large win).

Facebook launch Dalvik KK MR2:
TotalTime: 3165
TotalTime: 3652
TotalTime: 3143
TotalTime: 3298
TotalTime: 3212
TotalTime: 3211

Facebook launch TOT before:
WaitTime: 3702
WaitTime: 3616
WaitTime: 3616
WaitTime: 3687
WaitTime: 3742
WaitTime: 3767

After optimizations:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

LinkInterfaceMethods no longer one of the hottest methods, new list:
4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)
3.07% art::DexFile::FindClassDef(char const*) const
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
2.90% art::DexFile::FindStringId(char const*) const

Bug: 18054905
Bug: 16828525

Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321

9 years ago[native bridge] Make sure we always unload the native bridge
Calin Juravle [Wed, 22 Oct 2014 20:02:23 +0000 (21:02 +0100)]
[native bridge] Make sure we always unload the native bridge

libnativebridge may allocate some resources during loading and
intialization and de-allocate them when unloading. This makes sure that
we don't leak anything.

Bug: 18097480

(cherry picked from commit 07d83c7a25022064ac0a8dac4fe2a7a38681fa4b)

Change-Id: I3a5155a6760399ccfaf9130c72679615a3d4f2e7

9 years ago[native bridge] Add test to verify code_cache existance.
Calin Juravle [Wed, 22 Oct 2014 19:17:58 +0000 (20:17 +0100)]
[native bridge] Add test to verify code_cache existance.

Bug: 18027433

(cherry picked from commit 44a3506627833deb17d21d6a7d51245a5af2c3e9)

Change-Id: I9ce578949dbe522d5033465df7ca49fdd3aa3cbf

9 years agoFix JDWP Virtualmachine.Resume command
Sebastien Hertz [Tue, 14 Oct 2014 15:27:15 +0000 (17:27 +0200)]
Fix JDWP Virtualmachine.Resume command

We used to call ThreadList::UndoDebuggerSuspensions but this is not
correct. Indeed Virtualmachine.Resume command should be performed
as many times as all threads have been suspended (either by the
Virtualmachine.Suspend command or the application of suspend policy
ALL for event).

This CL fixes this issue by adding ThreadList::ResumeAllForDebugger.
It decrements suspend count and debug suspend count by 1 (globally
and for each thread).

It also handles the case where Virtualmachine.Resume is called while
threads have not been suspended (global debug suspend count is 0). In
this case we just print a warning and do nothing.

Bug: 17974047

(cherry picked from commit 253fa555d9424a56c52879449eabe73d5c96cf61)

Change-Id: I38b38240f84f141670506e88fa5c2480f856fdd6

9 years agoMerge "Only watch location for BREAKPOINT event" into lmp-mr1-dev
Sebastien Hertz [Fri, 24 Oct 2014 07:57:49 +0000 (07:57 +0000)]
Merge "Only watch location for BREAKPOINT event" into lmp-mr1-dev

9 years agoam c63a505a: Fix concurrent start bytes race
Mathieu Chartier [Fri, 24 Oct 2014 00:44:43 +0000 (00:44 +0000)]
am c63a505a: Fix concurrent start bytes race

* commit 'c63a505ae9992cc6ad154179734f078594c72d01':
  Fix concurrent start bytes race

9 years agoFix concurrent start bytes race
Mathieu Chartier [Thu, 23 Oct 2014 00:18:34 +0000 (17:18 -0700)]
Fix concurrent start bytes race

Previously, we set concurrent start bytes to max int when we
requested a concurrent GC, but there was a race if another thread
was doing another GC and had already completed GrowForUtilization
but had not yet finished the GC. This meant that the thread doing
the GC would update the concurrent start bytes properly, but the
allocating thread would re-update it to max int. Then when the
concurrent GC thread woke up, it would call WaitForGcToComplete
and see that there was a collector running and avoid doing the
concurrent GC, leaving the concurrent start bytes set to max int.

This meant that there would be no more concurrent GC until either
the next explicit GC or the next GC for alloc.

The fix is to only set concurrent start bytes to max int inside of
the CollectGarbageInternal code such that there isn't any way for
two threads to race.

Bug: 17942071
Change-Id: I2a4b067d99ae0aeebcc32fa4970024dcdff2ddc3
(cherry picked from commit 0133ec454d8dd3fa5ffe35649b5704aa18f15a49)

9 years agoFix concurrent start bytes race
Mathieu Chartier [Thu, 23 Oct 2014 00:18:34 +0000 (17:18 -0700)]
Fix concurrent start bytes race

Previously, we set concurrent start bytes to max int when we
requested a concurrent GC, but there was a race if another thread
was doing another GC and had already completed GrowForUtilization
but had not yet finished the GC. This meant that the thread doing
the GC would update the concurrent start bytes properly, but the
allocating thread would re-update it to max int. Then when the
concurrent GC thread woke up, it would call WaitForGcToComplete
and see that there was a collector running and avoid doing the
concurrent GC, leaving the concurrent start bytes set to max int.

This meant that there would be no more concurrent GC until either
the next explicit GC or the next GC for alloc.

The fix is to only set concurrent start bytes to max int inside of
the CollectGarbageInternal code such that there isn't any way for
two threads to race.

Bug: 17942071
Change-Id: I2a4b067d99ae0aeebcc32fa4970024dcdff2ddc3

9 years agoFixed debugger for threads attached from JNI
Daniel Mihalyi [Mon, 20 Oct 2014 09:47:56 +0000 (11:47 +0200)]
Fixed debugger for threads attached from JNI

Dbg::PostThreadStart was not invoked in Thread::Attach,
thus when attaching existing native thread to JNI, JDWP
events from that thread are not handled correctly by the
debugger, because the thread keeps being unannounced.

The issue was reproduced on Eclipse 4.3 and 4.4.

Bug: 18030371
(cherry picked from commit dfafeef139dbc77e86fdb465d960b4a17a7ac4a0)

Change-Id: Ia91dcf1aa98913aea2742c90b3e21b10d2cb36d4
Signed-off-by: Daniel Mihalyi <daniel.mihalyi@mattakis.com>
9 years agoAvoid strict-aliasing problems with Handles.
Ian Rogers [Tue, 21 Oct 2014 22:05:36 +0000 (15:05 -0700)]
Avoid strict-aliasing problems with Handles.

Replace use of reinterpret_cast with down_cast.

Bug: 18074773

Change-Id: Id42d462f2798f69a2210e5912f441c868b8b5812
(cherry picked from commit b5cb18a116dce45fc077b3f5b94af9e521e79e8d)

9 years agoShut down FaultManager after shutting down threads.
Vladimir Marko [Mon, 20 Oct 2014 17:13:22 +0000 (18:13 +0100)]
Shut down FaultManager after shutting down threads.

Bug: 17703163

(cherry picked from commit 2beeb82523bd3b8015851b69ccd088553ec0c226)

Change-Id: Ic4beae99734ec15b8ead362fbf76a69eceae5980

9 years agoFix mac build (second attempt)
Dmitriy Ivanov [Wed, 15 Oct 2014 00:55:28 +0000 (17:55 -0700)]
Fix mac build (second attempt)

  It appears that the version of mac ld with
  -export_dynamic is pretty recent.

  Remove -export_dynamic to fix build for older
  mac versions (?)

(cherry picked from commit 8b5b69813ef4d718db2e38e51867883511a3eeea)

Change-Id: I272d4b2c95411cc8126f27468f5199ff932fc9ef

9 years agoFixing mac build
Dmitriy Ivanov [Tue, 14 Oct 2014 19:18:10 +0000 (12:18 -0700)]
Fixing mac build

 MacOS static linker does not understand --export-dynamic
 and --version-script. According to man ld there is
 -export_dynamic option which should do the same
 thing.

(cherry picked from commit 1d74e57fa22fbcad1e14d776c771472b2d8438fb)

Change-Id: If9c096e099c8c070b62dda87dd0ed3ce77addcd6

9 years agoUntie gtest executables from LD_PRELOAD
Dmitriy Ivanov [Tue, 14 Oct 2014 18:38:46 +0000 (11:38 -0700)]
Untie gtest executables from LD_PRELOAD

Bug: 15345057
Bug: 15426766

(cherry picked from commit 8508a436efa7979ad54f644e60dad483c8499be2)

Change-Id: Id710c87c050f573fec1e4c36f06f88def5de5887

9 years agoRemove libsigchain from LD_PRELOADS
Dmitriy Ivanov [Tue, 7 Oct 2014 20:43:23 +0000 (13:43 -0700)]
Remove libsigchain from LD_PRELOADS

  Link sigchain.cc statically with dalvikvm, app_process,
  surfaceflinger, dex2oat, patchoat and objdump.

  Replace libsigchain.so with dummy implementaions to avoid
  situations when it is used incorrectly.

Bug: 15345057
Bug: 15426766

(cherry picked from commit f57874dddefc03fef9ad36fbdd87e39a08a8d641)

Change-Id: I07fe3ca4eeef423d78d7e9a639f03fc59aae3b29

9 years agoam 4b4af816: am 1f24296c: Add way to ensure we are at the front of the sigaction...
Mathieu Chartier [Fri, 17 Oct 2014 18:52:25 +0000 (18:52 +0000)]
am 4b4af816: am 1f24296c: Add way to ensure we are at the front of the sigaction chain

* commit '4b4af816f2c5924cc173c84bc62c12d57123442e':
  Add way to ensure we are at the front of the sigaction chain

9 years agoMerge "Add test for equals and hashCode in ParameterizedType" into lmp-mr1-dev
Narayan Kamath [Fri, 17 Oct 2014 11:19:10 +0000 (11:19 +0000)]
Merge "Add test for equals and hashCode in ParameterizedType" into lmp-mr1-dev

9 years agoam 1f24296c: Add way to ensure we are at the front of the sigaction chain
Mathieu Chartier [Fri, 17 Oct 2014 07:29:32 +0000 (07:29 +0000)]
am 1f24296c: Add way to ensure we are at the front of the sigaction chain

* commit '1f24296c7c8a6501ee2388c0d20b48f471b48660':
  Add way to ensure we are at the front of the sigaction chain

9 years agoTracking change to make Class.getDeclaredFields/Methods public
Brian Carlstrom [Fri, 17 Oct 2014 05:02:23 +0000 (22:02 -0700)]
Tracking change to make Class.getDeclaredFields/Methods public

Bug: 17375269
Change-Id: Ib3bc256e2034258210e153ff664ee9b1f2d806f7

9 years agoAdd way to ensure we are at the front of the sigaction chain
Mathieu Chartier [Wed, 15 Oct 2014 23:59:47 +0000 (16:59 -0700)]
Add way to ensure we are at the front of the sigaction chain

Calling this after jni_on_load fixes the unity apps. This is
not exactly correct since we may already have the following chain.

Start up:
Us -> debuggerd

After app goes in front:
App -> us -> debuggerd

After we put ourself back at the front:
Us -> app -> us -> app -> .... stack overflow.

Bug: 17620677
Change-Id: I9183997e3d5ebd51c320b5d51425be5142e938f3

9 years agoam 1fc7a271: am edfc4ca2: Fix oatdump for no image
Mathieu Chartier [Wed, 15 Oct 2014 18:13:41 +0000 (18:13 +0000)]
am 1fc7a271: am edfc4ca2: Fix oatdump for no image

* commit '1fc7a271f6c8ce844f0af67165c437c859e4e20c':
  Fix oatdump for no image

9 years agoam edfc4ca2: Fix oatdump for no image
Mathieu Chartier [Wed, 15 Oct 2014 18:09:19 +0000 (18:09 +0000)]
am edfc4ca2: Fix oatdump for no image

* commit 'edfc4ca2c8e1de6a1d42700cc0bc41d5b243ea04':
  Fix oatdump for no image

9 years agoFix oatdump for no image
Mathieu Chartier [Wed, 15 Oct 2014 17:39:23 +0000 (10:39 -0700)]
Fix oatdump for no image

Added MemMap::Init if we dont initialize the runtime.

(cherry picked from commit d424d0856927a5d771644b0ef18cb48ef8c04817)
Bug: 18000219

Change-Id: Ice068edea04708551b3fb8b75eae4e97758a18f9

9 years agoFix oatdump for no image
Mathieu Chartier [Wed, 15 Oct 2014 17:39:23 +0000 (10:39 -0700)]
Fix oatdump for no image

Added MemMap::Init if we dont initialize the runtime.

(cherry picked from commit d424d0856927a5d771644b0ef18cb48ef8c04817)
Bug: 18000219

Change-Id: Ice068edea04708551b3fb8b75eae4e97758a18f9

9 years agoMerge "Store exiting thread ids and names while tracing to output later." into lmp...
Jeff Hao [Wed, 15 Oct 2014 00:34:33 +0000 (00:34 +0000)]
Merge "Store exiting thread ids and names while tracing to output later." into lmp-mr1-dev

9 years agoam 84bda8bd: am c54e12a4: Change MemMap::maps_ to not be global variable
Mathieu Chartier [Tue, 14 Oct 2014 23:46:24 +0000 (23:46 +0000)]
am 84bda8bd: am c54e12a4: Change MemMap::maps_ to not be global variable

* commit '84bda8bd567a474bb1a72c45bcda397ca7ecc20b':
  Change MemMap::maps_ to not be global variable

9 years agoam c54e12a4: Change MemMap::maps_ to not be global variable
Mathieu Chartier [Tue, 14 Oct 2014 23:41:27 +0000 (23:41 +0000)]
am c54e12a4: Change MemMap::maps_ to not be global variable

* commit 'c54e12a413e16f90526318f1f466a900a717fbb0':
  Change MemMap::maps_ to not be global variable

9 years agoChange MemMap::maps_ to not be global variable
Mathieu Chartier [Tue, 14 Oct 2014 23:22:41 +0000 (16:22 -0700)]
Change MemMap::maps_ to not be global variable

Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.

(cherry picked from commit 6e88ef6b604a7a945a466784580c42e6554c1289)

Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962

9 years agoStore exiting thread ids and names while tracing to output later.
Jeff Hao [Tue, 14 Oct 2014 20:12:01 +0000 (13:12 -0700)]
Store exiting thread ids and names while tracing to output later.

Bug: 17909204
Change-Id: I4ce027af7c51fb310d6cdbdf067ae340e4c932ff

9 years agoam 0016e52f: am 5d1c1bbd: Check for errors in ThreadGroupReference JDWP commands
Sebastien Hertz [Tue, 14 Oct 2014 19:56:09 +0000 (19:56 +0000)]
am 0016e52f: am 5d1c1bbd: Check for errors in ThreadGroupReference JDWP commands

* commit '0016e52f1cdb0bb32f63d7b55590a4943dbc87b5':
  Check for errors in ThreadGroupReference JDWP commands

9 years agoam 5d1c1bbd: Check for errors in ThreadGroupReference JDWP commands
Sebastien Hertz [Tue, 14 Oct 2014 15:38:10 +0000 (15:38 +0000)]
am 5d1c1bbd: Check for errors in ThreadGroupReference JDWP commands

* commit '5d1c1bbd4c8a1727027d0ae69277af6f6f6badf3':
  Check for errors in ThreadGroupReference JDWP commands

9 years agoAdd test for equals and hashCode in ParameterizedType
Piotr Jastrzebski [Wed, 6 Aug 2014 11:02:48 +0000 (12:02 +0100)]
Add test for equals and hashCode in ParameterizedType

and GenericArrayType.

Bug: 14590652
Bug: https://code.google.com/p/android/issues/detail?id=74060

(cherry picked from commit 68b539ed7be2762bcab43f1c05174ef4a1d15625)

Change-Id: I9930d767b62658122981bc7550d150a78eeba943

9 years agoMerge "Optimize JDWP stack local values access" into lmp-mr1-dev
Sebastien Hertz [Mon, 13 Oct 2014 07:46:57 +0000 (07:46 +0000)]
Merge "Optimize JDWP stack local values access" into lmp-mr1-dev

9 years agoMerge "Handlerize throw location in DumpJavaStack" into lmp-mr1-dev
Ian Rogers [Sun, 12 Oct 2014 15:35:54 +0000 (15:35 +0000)]
Merge "Handlerize throw location in DumpJavaStack" into lmp-mr1-dev

9 years agoCheck for errors in ThreadGroupReference JDWP commands
Sebastien Hertz [Mon, 15 Sep 2014 17:21:30 +0000 (19:21 +0200)]
Check for errors in ThreadGroupReference JDWP commands

Returns INVALID_OBJECT error for null or invalid object. Also returns
INVALID_THREAD_GROUP error when the object is not a java.lang.ThreadGroup.

Removes unused Dbg::GetMainThreadGroupId method.

Bug: 17503230
(cherry picked from commit a06430c76981d545b5f2b64a7ef53c44c030cf73)

Change-Id: Ic39d3d2c45bf288fc22d908a3c90a3ca24f1c4d4

9 years agoHandlerize throw location in DumpJavaStack
Ian Rogers [Fri, 10 Oct 2014 22:57:19 +0000 (15:57 -0700)]
Handlerize throw location in DumpJavaStack

Handlerize this object and method during DumpJavaStack.
Bug: 17669899

Change-Id: I2e082137fe7f4c82257fc3b2fb36485a6981f369

9 years agoam fbf94774: am a4fee49a: Don\'t call dlsym from signal context in signal chain
Dave Allison [Fri, 10 Oct 2014 22:52:18 +0000 (22:52 +0000)]
am fbf94774: am a4fee49a: Don\'t call dlsym from signal context in signal chain

* commit 'fbf947740aea2d6e8a770f1b429593600bb3f249':
  Don't call dlsym from signal context in signal chain

9 years agoHold mutator lock in DdmSendHeapSegments for all spaces
Mathieu Chartier [Fri, 10 Oct 2014 19:45:50 +0000 (12:45 -0700)]
Hold mutator lock in DdmSendHeapSegments for all spaces

Previously we were releasing the mutator lock in DdmSendHeapSegments
and only reacquiring it for RosAlloc spaces. This was causing problems
since the HeapChunkCallback access object fields through mirror.

Bug: 17950534
Change-Id: I6bd71f43e84eae8585993da656bf1577095607a9

9 years agoOnly watch location for BREAKPOINT event
Sebastien Hertz [Wed, 8 Oct 2014 11:54:55 +0000 (13:54 +0200)]
Only watch location for BREAKPOINT event

This CL ensures we watch a location for BREAKPOINT event only. Other
events (single-step, method entry/exit, ...) are handled differently
and LocationOnly modifier is used as an event filter in this case.

This prevents from failing a check when we need to deoptimize for
non-breakpoint event.

Bug: 17908144

(cherry picked from commit 033aabf9789eda162e183ed34678d665dc903387)

Change-Id: Iaaf2954bcb67d21ae3df5d7ed3dcd86ed27c128a

9 years agoOptimize JDWP stack local values access
Sebastien Hertz [Mon, 1 Sep 2014 15:07:11 +0000 (17:07 +0200)]
Optimize JDWP stack local values access

The StackFrame.GetValues and StackFrame.SetValues JDWP commands can refer to
multiple variables at the same time in a given frame. However we used to walk
the stack until getting to the requested frame for each variable.

Now, we walk the stack only once until getting to the frame so the context is
initialized. Then we read/write value for each variable from this context.

Bug: 17343501
Bug: 15680615
(cherry picked from commit 8009f39c6d63181a6cd0e348ce732997dbdf3d20)

Change-Id: I70f64b25e4b20860f5446b8c540345d5e71ec4a9

9 years agoam a4fee49a: Don\'t call dlsym from signal context in signal chain
Dave Allison [Fri, 10 Oct 2014 15:41:50 +0000 (15:41 +0000)]
am a4fee49a: Don\'t call dlsym from signal context in signal chain

* commit 'a4fee49a5023a3cf8431597950ee87c711d0b81c':
  Don't call dlsym from signal context in signal chain

9 years agoMerge "ART: Stash any exception before dumping a stack" into lmp-mr1-dev
Brian Carlstrom [Fri, 10 Oct 2014 05:54:59 +0000 (05:54 +0000)]
Merge "ART: Stash any exception before dumping a stack" into lmp-mr1-dev

9 years agoDon't call dlsym from signal context in signal chain
Dave Allison [Tue, 16 Sep 2014 17:01:01 +0000 (10:01 -0700)]
Don't call dlsym from signal context in signal chain

It is dangerous to call dlsym from within a signal context
since it takes a lock and can lead to a mutex reentry attempt if
timing is bad.

This change adds an initialization function to the signal chain
that calls dlsym for sigaction and sigprocmask from outside the
signal context (from Runtime::Init()).  The results are cached
in a static variable and used from within the signal context if
necessary.

However, tests don't necessarily call Runtime::Init() so we also
need to deal with the case where the signal chain is not initialized
and perform a lazy initialization from inside sigaction or sigprocmask.
This is always outside a signal context since we have not initialized
the runtime.

Bug: 1749857117896006

(cherry picked from commit cefcea838729287a04174664a76514dd793dd77d)

Change-Id: I9bf8540a1250eadf977ff9af249dbe1c73b5ac63

9 years agoam 056e8fa7: am b90132cb: Fix race in thread list destructor
Mathieu Chartier [Fri, 10 Oct 2014 00:31:20 +0000 (00:31 +0000)]
am 056e8fa7: am b90132cb: Fix race in thread list destructor

* commit '056e8fa7fe39d5b24d17bfd7768c6325984788ad':
  Fix race in thread list destructor

9 years agoam b90132cb: Fix race in thread list destructor
Mathieu Chartier [Thu, 9 Oct 2014 20:46:51 +0000 (20:46 +0000)]
am b90132cb: Fix race in thread list destructor

* commit 'b90132cb5132eaeb4dbfca1e63d79b4005dacec5':
  Fix race in thread list destructor

9 years agoFix race in thread list destructor
Mathieu Chartier [Thu, 9 Oct 2014 19:57:58 +0000 (12:57 -0700)]
Fix race in thread list destructor

The ThreadList::Contains wasn't being guarded by the thread list
lock, which could cause a corrupted thread list if another thread
unregistered itself while std::find was searching the thread list.

Bug: 17896374
Change-Id: I629b1eac3473e3cf7355ebde9080dfd7c58af73a

9 years agoam 7b579f56: am b6404fe0: Disable kEnableJavaStackTraceHandler
Brian Carlstrom [Thu, 9 Oct 2014 19:23:13 +0000 (19:23 +0000)]
am 7b579f56: am b6404fe0: Disable kEnableJavaStackTraceHandler

* commit '7b579f56695d800b05cab0040d229c34c68cca24':
  Disable kEnableJavaStackTraceHandler

9 years agoam b6404fe0: Disable kEnableJavaStackTraceHandler
Brian Carlstrom [Thu, 9 Oct 2014 19:11:15 +0000 (19:11 +0000)]
am b6404fe0: Disable kEnableJavaStackTraceHandler

* commit 'b6404fe0bb782cbbccda88903901fe0096a741d5':
  Disable kEnableJavaStackTraceHandler

9 years agoDump mutator lock for thread suspend timeout
Mathieu Chartier [Wed, 8 Oct 2014 19:17:44 +0000 (12:17 -0700)]
Dump mutator lock for thread suspend timeout

Should help us see if thread suspend timeouts are due to someone
holding on the mutator lock for too long or if it is a missed
futex wake.

Bug: 17837911
Change-Id: I3417156a78f574076d5da17c86836c5a7c76084a

9 years agoDisable kEnableJavaStackTraceHandler
Brian Carlstrom [Wed, 8 Oct 2014 20:56:25 +0000 (13:56 -0700)]
Disable kEnableJavaStackTraceHandler

Bug: 17890306
Change-Id: I76d1d1b709cfcb0cf8fe02f5d28fb746909d682f

9 years agoMerge "Fix mips thread offsets" into lmp-mr1-dev
Mathieu Chartier [Tue, 7 Oct 2014 23:54:38 +0000 (23:54 +0000)]
Merge "Fix mips thread offsets" into lmp-mr1-dev

9 years agoFix mips thread offsets
Mathieu Chartier [Tue, 7 Oct 2014 23:20:14 +0000 (16:20 -0700)]
Fix mips thread offsets

Bug: 17898168
Change-Id: Ia528236458323d86c40fe7a729d2183df3547122

9 years agoam d2aa3bb9: am b9001abf: Add extra logging for lock contention
Mathieu Chartier [Fri, 3 Oct 2014 21:33:22 +0000 (21:33 +0000)]
am d2aa3bb9: am b9001abf: Add extra logging for lock contention

* commit 'd2aa3bb95042fa1d5e1d2b5f9435c7f88f328e9e':
  Add extra logging for lock contention

9 years agoam b9001abf: Add extra logging for lock contention
Mathieu Chartier [Fri, 3 Oct 2014 21:18:33 +0000 (21:18 +0000)]
am b9001abf: Add extra logging for lock contention

* commit 'b9001abff3a45f1ae90536da7dd1ec28a6ae0174':
  Add extra logging for lock contention

9 years agoAdd extra logging for lock contention
Mathieu Chartier [Fri, 3 Oct 2014 20:28:46 +0000 (13:28 -0700)]
Add extra logging for lock contention

When we get contention which is longer than kLongWaitMs (= 100ms) we
log to logcat.

Example output:
W/art     ( 9960): Long monitor contention event with owner method=void com.android.server.am.BroadcastQueue.processNextBroadcast(boolean) from BroadcastQueue.java:542 waiters=1 for 243ms

Bug: 17787391
Change-Id: Id1f92d9c41ec909d221871ecc2ff6181dcec2ed4

9 years agoART: Fix verifier fail message.
Elena Sayapina [Fri, 15 Aug 2014 08:52:42 +0000 (15:52 +0700)]
ART: Fix verifier fail message.

Verifier failure message is corrupted.
The verification failure reason overlaps verification failure location.
MethodVerifier::Fail() method creates failure message stream by
std::ostringstream(failure location) constructor which by default
sets the stream's position indicator to the begging of that stream.
Inserting failure reason to the stream by "<<" then overrides the failure location.
Using std::ostringstream(failure location, std::ostringstream::ate) fixes the issue
by setting the stream's position indicator to the end of the stream on opening.

Signed-off-by: Elena Sayapina <elena.v.sayapina@intel.com>
(cherry picked from commit 78480ecb348beee3f27731e12ec06ade032521d6)

bug: 17790245

Change-Id: I31955e859a4eb01d05318395901e8cd229a6c33c

9 years agoART: Stash any exception before dumping a stack
Andreas Gampe [Fri, 3 Oct 2014 04:00:06 +0000 (21:00 -0700)]
ART: Stash any exception before dumping a stack

Dumping a managed stack entails dumping held locks, in the process
of which the verifier will be run. The verifier works under the
assumption that there were no exceptions when started. This
assumption is violated for example on certain JNI aborts.

The solution is to stash any pending exception before dumping the
stack, and re-installing it afterwards.

Bug: 17669899
Change-Id: I3cd0526b52fce1acaa35fe0e419176478c82be22

9 years agoam 70a96024: am 5be30072: ART: Remove wrong DCHECK
Andreas Gampe [Thu, 2 Oct 2014 05:59:19 +0000 (05:59 +0000)]
am 70a96024: am 5be30072: ART: Remove wrong DCHECK

* commit '70a96024c3f708bda3f007517c248c4ad321ee89':
  ART: Remove wrong DCHECK

9 years agoam 5be30072: ART: Remove wrong DCHECK
Andreas Gampe [Thu, 2 Oct 2014 05:56:38 +0000 (05:56 +0000)]
am 5be30072: ART: Remove wrong DCHECK

* commit '5be30072c5a750617dc3f9380776d074f26d9f32':
  ART: Remove wrong DCHECK