hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp
changeset 9176 42d9d1010f38
parent 7397 5b173b4ca846
child 10565 dc90c239f4ec
equal deleted inserted replaced
9175:80221fe09772 9176:42d9d1010f38
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    45   _kind = G1SATBCT;
    45   _kind = G1SATBCT;
    46 }
    46 }
    47 
    47 
    48 
    48 
    49 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
    49 void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
    50   assert(pre_val->is_oop_or_null(true), "Error");
    50   // Nulls should have been already filtered.
       
    51   assert(pre_val->is_oop(true), "Error");
       
    52 
    51   if (!JavaThread::satb_mark_queue_set().is_active()) return;
    53   if (!JavaThread::satb_mark_queue_set().is_active()) return;
    52   Thread* thr = Thread::current();
    54   Thread* thr = Thread::current();
    53   if (thr->is_Java_thread()) {
    55   if (thr->is_Java_thread()) {
    54     JavaThread* jt = (JavaThread*)thr;
    56     JavaThread* jt = (JavaThread*)thr;
    55     jt->satb_mark_queue().enqueue(pre_val);
    57     jt->satb_mark_queue().enqueue(pre_val);
    56   } else {
    58   } else {
    57     MutexLocker x(Shared_SATB_Q_lock);
    59     MutexLocker x(Shared_SATB_Q_lock);
    58     JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val);
    60     JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val);
    59   }
       
    60 }
       
    61 
       
    62 // When we know the current java thread:
       
    63 template <class T> void
       
    64 G1SATBCardTableModRefBS::write_ref_field_pre_static(T* field,
       
    65                                                     oop new_val,
       
    66                                                     JavaThread* jt) {
       
    67   if (!JavaThread::satb_mark_queue_set().is_active()) return;
       
    68   T heap_oop = oopDesc::load_heap_oop(field);
       
    69   if (!oopDesc::is_null(heap_oop)) {
       
    70     oop pre_val = oopDesc::decode_heap_oop_not_null(heap_oop);
       
    71     assert(pre_val->is_oop(true /* ignore mark word */), "Error");
       
    72     jt->satb_mark_queue().enqueue(pre_val);
       
    73   }
    61   }
    74 }
    62 }
    75 
    63 
    76 template <class T> void
    64 template <class T> void
    77 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) {
    65 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) {