src/share/vm/shark/sharkCacheDecache.hpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4314
2cd5e15048e6
child 6876
710a3c8b516e
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

twisti@2047 1 /*
stefank@2314 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
twisti@2047 3 * Copyright 2008, 2009 Red Hat, Inc.
twisti@2047 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@2047 5 *
twisti@2047 6 * This code is free software; you can redistribute it and/or modify it
twisti@2047 7 * under the terms of the GNU General Public License version 2 only, as
twisti@2047 8 * published by the Free Software Foundation.
twisti@2047 9 *
twisti@2047 10 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@2047 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@2047 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@2047 13 * version 2 for more details (a copy is included in the LICENSE file that
twisti@2047 14 * accompanied this code).
twisti@2047 15 *
twisti@2047 16 * You should have received a copy of the GNU General Public License version
twisti@2047 17 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@2047 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@2047 19 *
twisti@2047 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@2047 21 * or visit www.oracle.com if you need additional information or have any
twisti@2047 22 * questions.
twisti@2047 23 *
twisti@2047 24 */
twisti@2047 25
stefank@2314 26 #ifndef SHARE_VM_SHARK_SHARKCACHEDECACHE_HPP
stefank@2314 27 #define SHARE_VM_SHARK_SHARKCACHEDECACHE_HPP
stefank@2314 28
stefank@2314 29 #include "ci/ciMethod.hpp"
stefank@2314 30 #include "code/debugInfoRec.hpp"
stefank@2314 31 #include "shark/sharkBuilder.hpp"
stefank@2314 32 #include "shark/sharkFunction.hpp"
stefank@2314 33 #include "shark/sharkStateScanner.hpp"
stefank@2314 34
twisti@2047 35 // Class hierarchy:
twisti@2047 36 // - SharkStateScanner
twisti@2047 37 // - SharkCacherDecacher
twisti@2047 38 // - SharkDecacher
twisti@2047 39 // - SharkJavaCallDecacher
twisti@2047 40 // - SharkVMCallDecacher
twisti@2047 41 // - SharkTrapDecacher
twisti@2047 42 // - SharkCacher
twisti@2047 43 // - SharkJavaCallCacher
twisti@2047 44 // - SharkVMCallCacher
twisti@2047 45 // - SharkFunctionEntryCacher
twisti@2047 46 // - SharkNormalEntryCacher
twisti@2047 47 // - SharkOSREntryCacher
twisti@2047 48
twisti@2047 49 class SharkCacherDecacher : public SharkStateScanner {
twisti@2047 50 protected:
twisti@2047 51 SharkCacherDecacher(SharkFunction* function)
twisti@2047 52 : SharkStateScanner(function) {}
twisti@2047 53
twisti@2047 54 // Helper
twisti@2047 55 protected:
twisti@2047 56 static int adjusted_offset(SharkValue* value, int offset) {
twisti@2047 57 if (value->is_two_word())
twisti@2047 58 offset--;
twisti@2047 59 return offset;
twisti@2047 60 }
twisti@2047 61 };
twisti@2047 62
twisti@2047 63 class SharkDecacher : public SharkCacherDecacher {
twisti@2047 64 protected:
twisti@2047 65 SharkDecacher(SharkFunction* function, int bci)
twisti@2047 66 : SharkCacherDecacher(function), _bci(bci) {}
twisti@2047 67
twisti@2047 68 private:
twisti@2047 69 int _bci;
twisti@2047 70
twisti@2047 71 protected:
twisti@2047 72 int bci() const {
twisti@2047 73 return _bci;
twisti@2047 74 }
twisti@2047 75
twisti@2047 76 private:
twisti@2047 77 int _pc_offset;
twisti@2047 78 OopMap* _oopmap;
twisti@2047 79 GrowableArray<ScopeValue*>* _exparray;
twisti@2047 80 GrowableArray<MonitorValue*>* _monarray;
twisti@2047 81 GrowableArray<ScopeValue*>* _locarray;
twisti@2047 82
twisti@2047 83 private:
twisti@2047 84 int pc_offset() const {
twisti@2047 85 return _pc_offset;
twisti@2047 86 }
twisti@2047 87 OopMap* oopmap() const {
twisti@2047 88 return _oopmap;
twisti@2047 89 }
twisti@2047 90 GrowableArray<ScopeValue*>* exparray() const {
twisti@2047 91 return _exparray;
twisti@2047 92 }
twisti@2047 93 GrowableArray<MonitorValue*>* monarray() const {
twisti@2047 94 return _monarray;
twisti@2047 95 }
twisti@2047 96 GrowableArray<ScopeValue*>* locarray() const {
twisti@2047 97 return _locarray;
twisti@2047 98 }
twisti@2047 99
twisti@2047 100 // Callbacks
twisti@2047 101 protected:
twisti@2047 102 void start_frame();
twisti@2047 103
twisti@2047 104 void start_stack(int stack_depth);
twisti@2047 105 void process_stack_slot(int index, SharkValue** value, int offset);
twisti@2047 106
twisti@2047 107 void start_monitors(int num_monitors);
twisti@2047 108 void process_monitor(int index, int box_offset, int obj_offset);
twisti@2047 109
twisti@2047 110 void process_oop_tmp_slot(llvm::Value** value, int offset);
twisti@2047 111 void process_method_slot(llvm::Value** value, int offset);
twisti@2047 112 void process_pc_slot(int offset);
twisti@2047 113
twisti@2047 114 void start_locals();
twisti@2047 115 void process_local_slot(int index, SharkValue** value, int offset);
twisti@2047 116
twisti@2047 117 void end_frame();
twisti@2047 118
twisti@2047 119 // oopmap and debuginfo helpers
twisti@2047 120 private:
twisti@2047 121 static int oopmap_slot_munge(int offset) {
twisti@2047 122 return SharkStack::oopmap_slot_munge(offset);
twisti@2047 123 }
twisti@2047 124 static VMReg slot2reg(int offset) {
twisti@2047 125 return SharkStack::slot2reg(offset);
twisti@2047 126 }
twisti@2047 127 static Location slot2loc(int offset, Location::Type type) {
twisti@2047 128 return Location::new_stk_loc(type, offset * wordSize);
twisti@2047 129 }
twisti@2047 130 static LocationValue* slot2lv(int offset, Location::Type type) {
twisti@2047 131 return new LocationValue(slot2loc(offset, type));
twisti@2047 132 }
twisti@2047 133 static Location::Type location_type(SharkValue** addr, bool maybe_two_word) {
twisti@2047 134 // low addresses this end
twisti@2047 135 // Type 32-bit 64-bit
twisti@2047 136 // ----------------------------------------------------
twisti@2047 137 // stack[0] local[3] jobject oop oop
twisti@2047 138 // stack[1] local[2] NULL normal lng
twisti@2047 139 // stack[2] local[1] jlong normal invalid
twisti@2047 140 // stack[3] local[0] jint normal normal
twisti@2047 141 //
twisti@2047 142 // high addresses this end
twisti@2047 143
twisti@2047 144 SharkValue *value = *addr;
twisti@2047 145 if (value) {
twisti@2047 146 if (value->is_jobject())
twisti@2047 147 return Location::oop;
twisti@2047 148 #ifdef _LP64
twisti@2047 149 if (value->is_two_word())
twisti@2047 150 return Location::invalid;
twisti@2047 151 #endif // _LP64
twisti@2047 152 return Location::normal;
twisti@2047 153 }
twisti@2047 154 else {
twisti@2047 155 if (maybe_two_word) {
twisti@2047 156 value = *(addr - 1);
twisti@2047 157 if (value && value->is_two_word()) {
twisti@2047 158 #ifdef _LP64
twisti@2047 159 if (value->is_jlong())
twisti@2047 160 return Location::lng;
twisti@2047 161 if (value->is_jdouble())
twisti@2047 162 return Location::dbl;
twisti@2047 163 ShouldNotReachHere();
twisti@2047 164 #else
twisti@2047 165 return Location::normal;
twisti@2047 166 #endif // _LP64
twisti@2047 167 }
twisti@2047 168 }
twisti@2047 169 return Location::invalid;
twisti@2047 170 }
twisti@2047 171 }
twisti@2047 172
twisti@2047 173 // Stack slot helpers
twisti@2047 174 protected:
twisti@2047 175 virtual bool stack_slot_needs_write(int index, SharkValue* value) = 0;
twisti@2047 176 virtual bool stack_slot_needs_oopmap(int index, SharkValue* value) = 0;
twisti@2047 177 virtual bool stack_slot_needs_debuginfo(int index, SharkValue* value) = 0;
twisti@2047 178
twisti@2047 179 static Location::Type stack_location_type(int index, SharkValue** addr) {
twisti@2047 180 return location_type(addr, *addr == NULL);
twisti@2047 181 }
twisti@2047 182
twisti@2047 183 // Local slot helpers
twisti@2047 184 protected:
twisti@2047 185 virtual bool local_slot_needs_write(int index, SharkValue* value) = 0;
twisti@2047 186 virtual bool local_slot_needs_oopmap(int index, SharkValue* value) = 0;
twisti@2047 187 virtual bool local_slot_needs_debuginfo(int index, SharkValue* value) = 0;
twisti@2047 188
twisti@2047 189 static Location::Type local_location_type(int index, SharkValue** addr) {
twisti@2047 190 return location_type(addr, index > 0);
twisti@2047 191 }
twisti@2047 192
twisti@2047 193 // Writer helper
twisti@2047 194 protected:
twisti@4314 195 void write_value_to_frame(llvm::Type* type,
twisti@2047 196 llvm::Value* value,
twisti@2047 197 int offset);
twisti@2047 198 };
twisti@2047 199
twisti@2047 200 class SharkJavaCallDecacher : public SharkDecacher {
twisti@2047 201 public:
twisti@2047 202 SharkJavaCallDecacher(SharkFunction* function, int bci, ciMethod* callee)
twisti@2047 203 : SharkDecacher(function, bci), _callee(callee) {}
twisti@2047 204
twisti@2047 205 private:
twisti@2047 206 ciMethod* _callee;
twisti@2047 207
twisti@2047 208 protected:
twisti@2047 209 ciMethod* callee() const {
twisti@2047 210 return _callee;
twisti@2047 211 }
twisti@2047 212
twisti@2047 213 // Stack slot helpers
twisti@2047 214 protected:
twisti@2047 215 bool stack_slot_needs_write(int index, SharkValue* value) {
twisti@2047 216 return value && (index < callee()->arg_size() || value->is_jobject());
twisti@2047 217 }
twisti@2047 218 bool stack_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 219 return value && value->is_jobject() && index >= callee()->arg_size();
twisti@2047 220 }
twisti@2047 221 bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 222 return index >= callee()->arg_size();
twisti@2047 223 }
twisti@2047 224
twisti@2047 225 // Local slot helpers
twisti@2047 226 protected:
twisti@2047 227 bool local_slot_needs_write(int index, SharkValue* value) {
twisti@2047 228 return value && value->is_jobject();
twisti@2047 229 }
twisti@2047 230 bool local_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 231 return value && value->is_jobject();
twisti@2047 232 }
twisti@2047 233 bool local_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 234 return true;
twisti@2047 235 }
twisti@2047 236 };
twisti@2047 237
twisti@2047 238 class SharkVMCallDecacher : public SharkDecacher {
twisti@2047 239 public:
twisti@2047 240 SharkVMCallDecacher(SharkFunction* function, int bci)
twisti@2047 241 : SharkDecacher(function, bci) {}
twisti@2047 242
twisti@2047 243 // Stack slot helpers
twisti@2047 244 protected:
twisti@2047 245 bool stack_slot_needs_write(int index, SharkValue* value) {
twisti@2047 246 return value && value->is_jobject();
twisti@2047 247 }
twisti@2047 248 bool stack_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 249 return value && value->is_jobject();
twisti@2047 250 }
twisti@2047 251 bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 252 return true;
twisti@2047 253 }
twisti@2047 254
twisti@2047 255 // Local slot helpers
twisti@2047 256 protected:
twisti@2047 257 bool local_slot_needs_write(int index, SharkValue* value) {
twisti@2047 258 return value && value->is_jobject();
twisti@2047 259 }
twisti@2047 260 bool local_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 261 return value && value->is_jobject();
twisti@2047 262 }
twisti@2047 263 bool local_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 264 return true;
twisti@2047 265 }
twisti@2047 266 };
twisti@2047 267
twisti@2047 268 class SharkTrapDecacher : public SharkDecacher {
twisti@2047 269 public:
twisti@2047 270 SharkTrapDecacher(SharkFunction* function, int bci)
twisti@2047 271 : SharkDecacher(function, bci) {}
twisti@2047 272
twisti@2047 273 // Stack slot helpers
twisti@2047 274 protected:
twisti@2047 275 bool stack_slot_needs_write(int index, SharkValue* value) {
twisti@2047 276 return value != NULL;
twisti@2047 277 }
twisti@2047 278 bool stack_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 279 return value && value->is_jobject();
twisti@2047 280 }
twisti@2047 281 bool stack_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 282 return true;
twisti@2047 283 }
twisti@2047 284
twisti@2047 285 // Local slot helpers
twisti@2047 286 protected:
twisti@2047 287 bool local_slot_needs_write(int index, SharkValue* value) {
twisti@2047 288 return value != NULL;
twisti@2047 289 }
twisti@2047 290 bool local_slot_needs_oopmap(int index, SharkValue* value) {
twisti@2047 291 return value && value->is_jobject();
twisti@2047 292 }
twisti@2047 293 bool local_slot_needs_debuginfo(int index, SharkValue* value) {
twisti@2047 294 return true;
twisti@2047 295 }
twisti@2047 296 };
twisti@2047 297
twisti@2047 298 class SharkCacher : public SharkCacherDecacher {
twisti@2047 299 protected:
twisti@2047 300 SharkCacher(SharkFunction* function)
twisti@2047 301 : SharkCacherDecacher(function) {}
twisti@2047 302
twisti@2047 303 // Callbacks
twisti@2047 304 protected:
twisti@2047 305 void process_stack_slot(int index, SharkValue** value, int offset);
twisti@2047 306
twisti@2047 307 void process_oop_tmp_slot(llvm::Value** value, int offset);
twisti@2047 308 virtual void process_method_slot(llvm::Value** value, int offset);
twisti@2047 309
twisti@2047 310 virtual void process_local_slot(int index, SharkValue** value, int offset);
twisti@2047 311
twisti@2047 312 // Stack slot helper
twisti@2047 313 protected:
twisti@2047 314 virtual bool stack_slot_needs_read(int index, SharkValue* value) = 0;
twisti@2047 315
twisti@2047 316 // Local slot helper
twisti@2047 317 protected:
twisti@2047 318 virtual bool local_slot_needs_read(int index, SharkValue* value) {
twisti@2047 319 return value && value->is_jobject();
twisti@2047 320 }
twisti@2047 321
twisti@2047 322 // Writer helper
twisti@2047 323 protected:
twisti@4314 324 llvm::Value* read_value_from_frame(llvm::Type* type, int offset);
twisti@2047 325 };
twisti@2047 326
twisti@2047 327 class SharkJavaCallCacher : public SharkCacher {
twisti@2047 328 public:
twisti@2047 329 SharkJavaCallCacher(SharkFunction* function, ciMethod* callee)
twisti@2047 330 : SharkCacher(function), _callee(callee) {}
twisti@2047 331
twisti@2047 332 private:
twisti@2047 333 ciMethod* _callee;
twisti@2047 334
twisti@2047 335 protected:
twisti@2047 336 ciMethod* callee() const {
twisti@2047 337 return _callee;
twisti@2047 338 }
twisti@2047 339
twisti@2047 340 // Stack slot helper
twisti@2047 341 protected:
twisti@2047 342 bool stack_slot_needs_read(int index, SharkValue* value) {
twisti@2047 343 return value && (index < callee()->return_type()->size() ||
twisti@2047 344 value->is_jobject());
twisti@2047 345 }
twisti@2047 346 };
twisti@2047 347
twisti@2047 348 class SharkVMCallCacher : public SharkCacher {
twisti@2047 349 public:
twisti@2047 350 SharkVMCallCacher(SharkFunction* function)
twisti@2047 351 : SharkCacher(function) {}
twisti@2047 352
twisti@2047 353 // Stack slot helper
twisti@2047 354 protected:
twisti@2047 355 bool stack_slot_needs_read(int index, SharkValue* value) {
twisti@2047 356 return value && value->is_jobject();
twisti@2047 357 }
twisti@2047 358 };
twisti@2047 359
twisti@2047 360 class SharkFunctionEntryCacher : public SharkCacher {
twisti@2047 361 public:
twisti@2047 362 SharkFunctionEntryCacher(SharkFunction* function, llvm::Value* method)
twisti@2047 363 : SharkCacher(function), _method(method) {}
twisti@2047 364
twisti@2047 365 private:
twisti@2047 366 llvm::Value* _method;
twisti@2047 367
twisti@2047 368 private:
twisti@2047 369 llvm::Value* method() const {
twisti@2047 370 return _method;
twisti@2047 371 }
twisti@2047 372
twisti@2047 373 // Method slot callback
twisti@2047 374 protected:
twisti@2047 375 void process_method_slot(llvm::Value** value, int offset);
twisti@2047 376
twisti@2047 377 // Stack slot helper
twisti@2047 378 protected:
twisti@2047 379 bool stack_slot_needs_read(int index, SharkValue* value) {
twisti@2047 380 ShouldNotReachHere(); // entry block shouldn't have stack
twisti@2047 381 }
twisti@2047 382
twisti@2047 383 // Local slot helper
twisti@2047 384 protected:
twisti@2047 385 bool local_slot_needs_read(int index, SharkValue* value) {
twisti@2047 386 return value != NULL;
twisti@2047 387 }
twisti@2047 388 };
twisti@2047 389
twisti@2047 390 class SharkNormalEntryCacher : public SharkFunctionEntryCacher {
twisti@2047 391 public:
twisti@2047 392 SharkNormalEntryCacher(SharkFunction* function, llvm::Value* method)
twisti@2047 393 : SharkFunctionEntryCacher(function, method) {}
twisti@2047 394 };
twisti@2047 395
twisti@2047 396 class SharkOSREntryCacher : public SharkFunctionEntryCacher {
twisti@2047 397 public:
twisti@2047 398 SharkOSREntryCacher(SharkFunction* function,
twisti@2047 399 llvm::Value* method,
twisti@2047 400 llvm::Value* osr_buf)
twisti@2047 401 : SharkFunctionEntryCacher(function, method),
twisti@2047 402 _osr_buf(
twisti@2047 403 builder()->CreateBitCast(
twisti@2047 404 osr_buf,
twisti@2047 405 llvm::PointerType::getUnqual(
twisti@2047 406 llvm::ArrayType::get(
twisti@2047 407 SharkType::intptr_type(),
twisti@2047 408 max_locals() + max_monitors() * 2)))) {}
twisti@2047 409
twisti@2047 410 private:
twisti@2047 411 llvm::Value* _osr_buf;
twisti@2047 412
twisti@2047 413 private:
twisti@2047 414 llvm::Value* osr_buf() const {
twisti@2047 415 return _osr_buf;
twisti@2047 416 }
twisti@2047 417
twisti@2047 418 // Callbacks
twisti@2047 419 protected:
twisti@2047 420 void process_monitor(int index, int box_offset, int obj_offset);
twisti@2047 421 void process_local_slot(int index, SharkValue** value, int offset);
twisti@2047 422
twisti@2047 423 // Helper
twisti@2047 424 private:
twisti@4314 425 llvm::Value* CreateAddressOfOSRBufEntry(int offset, llvm::Type* type);
twisti@2047 426 };
stefank@2314 427
stefank@2314 428 #endif // SHARE_VM_SHARK_SHARKCACHEDECACHE_HPP

mercurial