src/share/vm/shark/sharkCacheDecache.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial