comparison src/share/vm/c1/c1_Instruction.hpp @ 13086:096c224171c4

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 20 Nov 2013 00:10:38 +0100
parents ce0cc25bc5e2
children 2fd0fd493045
comparison
equal deleted inserted replaced
12782:92b7ec34ddfa 13086:096c224171c4
105 class UnsafeGetAndSetObject; 105 class UnsafeGetAndSetObject;
106 class UnsafePrefetch; 106 class UnsafePrefetch;
107 class UnsafePrefetchRead; 107 class UnsafePrefetchRead;
108 class UnsafePrefetchWrite; 108 class UnsafePrefetchWrite;
109 class ProfileCall; 109 class ProfileCall;
110 class ProfileReturnType;
110 class ProfileInvoke; 111 class ProfileInvoke;
111 class RuntimeCall; 112 class RuntimeCall;
112 class MemBar; 113 class MemBar;
113 class RangeCheckPredicate; 114 class RangeCheckPredicate;
114 #ifdef ASSERT 115 #ifdef ASSERT
209 virtual void do_UnsafePutObject(UnsafePutObject* x) = 0; 210 virtual void do_UnsafePutObject(UnsafePutObject* x) = 0;
210 virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) = 0; 211 virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) = 0;
211 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x) = 0; 212 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x) = 0;
212 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0; 213 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0;
213 virtual void do_ProfileCall (ProfileCall* x) = 0; 214 virtual void do_ProfileCall (ProfileCall* x) = 0;
215 virtual void do_ProfileReturnType (ProfileReturnType* x) = 0;
214 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; 216 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
215 virtual void do_RuntimeCall (RuntimeCall* x) = 0; 217 virtual void do_RuntimeCall (RuntimeCall* x) = 0;
216 virtual void do_MemBar (MemBar* x) = 0; 218 virtual void do_MemBar (MemBar* x) = 0;
217 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0; 219 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
218 #ifdef ASSERT 220 #ifdef ASSERT
319 321
320 void set_type(ValueType* type) { 322 void set_type(ValueType* type) {
321 assert(type != NULL, "type must exist"); 323 assert(type != NULL, "type must exist");
322 _type = type; 324 _type = type;
323 } 325 }
326
327 // Helper class to keep track of which arguments need a null check
328 class ArgsNonNullState {
329 private:
330 int _nonnull_state; // mask identifying which args are nonnull
331 public:
332 ArgsNonNullState()
333 : _nonnull_state(AllBits) {}
334
335 // Does argument number i needs a null check?
336 bool arg_needs_null_check(int i) const {
337 // No data is kept for arguments starting at position 33 so
338 // conservatively assume that they need a null check.
339 if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) {
340 return is_set_nth_bit(_nonnull_state, i);
341 }
342 return true;
343 }
344
345 // Set whether argument number i needs a null check or not
346 void set_arg_needs_null_check(int i, bool check) {
347 if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) {
348 if (check) {
349 _nonnull_state |= nth_bit(i);
350 } else {
351 _nonnull_state &= ~(nth_bit(i));
352 }
353 }
354 }
355 };
324 356
325 public: 357 public:
326 void* operator new(size_t size) throw() { 358 void* operator new(size_t size) throw() {
327 Compilation* c = Compilation::current(); 359 Compilation* c = Compilation::current();
328 void* res = c->arena()->Amalloc(size); 360 void* res = c->arena()->Amalloc(size);
564 virtual void input_values_do(ValueVisitor* f) = 0; 596 virtual void input_values_do(ValueVisitor* f) = 0;
565 virtual void state_values_do(ValueVisitor* f); 597 virtual void state_values_do(ValueVisitor* f);
566 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } 598 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ }
567 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } 599 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); }
568 600
569 virtual ciType* exact_type() const { return NULL; } 601 virtual ciType* exact_type() const;
570 virtual ciType* declared_type() const { return NULL; } 602 virtual ciType* declared_type() const { return NULL; }
571 603
572 // hashing 604 // hashing
573 virtual const char* name() const = 0; 605 virtual const char* name() const = 0;
574 HASHING1(Instruction, false, id()) // hashing disabled by default 606 HASHING1(Instruction, false, id()) // hashing disabled by default
687 719
688 // accessors 720 // accessors
689 int java_index() const { return _java_index; } 721 int java_index() const { return _java_index; }
690 722
691 virtual ciType* declared_type() const { return _declared_type; } 723 virtual ciType* declared_type() const { return _declared_type; }
692 virtual ciType* exact_type() const;
693 724
694 // generic 725 // generic
695 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 726 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
696 }; 727 };
697 728
804 ValueStack* state_before, bool needs_patching) 835 ValueStack* state_before, bool needs_patching)
805 : AccessField(obj, offset, field, is_static, state_before, needs_patching) 836 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
806 {} 837 {}
807 838
808 ciType* declared_type() const; 839 ciType* declared_type() const;
809 ciType* exact_type() const;
810 840
811 // generic 841 // generic
812 HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if needs patching or if volatile 842 HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if needs patching or if volatile
813 }; 843 };
814 844
1297 // accessors 1327 // accessors
1298 Value length() const { return _length; } 1328 Value length() const { return _length; }
1299 1329
1300 virtual bool needs_exception_state() const { return false; } 1330 virtual bool needs_exception_state() const { return false; }
1301 1331
1332 ciType* exact_type() const { return NULL; }
1302 ciType* declared_type() const; 1333 ciType* declared_type() const;
1303 1334
1304 // generic 1335 // generic
1305 virtual bool can_trap() const { return true; } 1336 virtual bool can_trap() const { return true; }
1306 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } 1337 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); }
1420 bool is_incompatible_class_change_check() const { 1451 bool is_incompatible_class_change_check() const {
1421 return check_flag(ThrowIncompatibleClassChangeErrorFlag); 1452 return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1422 } 1453 }
1423 1454
1424 ciType* declared_type() const; 1455 ciType* declared_type() const;
1425 ciType* exact_type() const;
1426 }; 1456 };
1427 1457
1428 1458
1429 LEAF(InstanceOf, TypeCheck) 1459 LEAF(InstanceOf, TypeCheck)
1430 public: 1460 public:
1488 LEAF(Intrinsic, StateSplit) 1518 LEAF(Intrinsic, StateSplit)
1489 private: 1519 private:
1490 vmIntrinsics::ID _id; 1520 vmIntrinsics::ID _id;
1491 Values* _args; 1521 Values* _args;
1492 Value _recv; 1522 Value _recv;
1493 int _nonnull_state; // mask identifying which args are nonnull 1523 ArgsNonNullState _nonnull_state;
1494 1524
1495 public: 1525 public:
1496 // preserves_state can be set to true for Intrinsics 1526 // preserves_state can be set to true for Intrinsics
1497 // which are guaranteed to preserve register state across any slow 1527 // which are guaranteed to preserve register state across any slow
1498 // cases; setting it to true does not mean that the Intrinsic can 1528 // cases; setting it to true does not mean that the Intrinsic can
1509 bool cantrap = true) 1539 bool cantrap = true)
1510 : StateSplit(type, state_before) 1540 : StateSplit(type, state_before)
1511 , _id(id) 1541 , _id(id)
1512 , _args(args) 1542 , _args(args)
1513 , _recv(NULL) 1543 , _recv(NULL)
1514 , _nonnull_state(AllBits)
1515 { 1544 {
1516 assert(args != NULL, "args must exist"); 1545 assert(args != NULL, "args must exist");
1517 ASSERT_VALUES 1546 ASSERT_VALUES
1518 set_flag(PreservesStateFlag, preserves_state); 1547 set_flag(PreservesStateFlag, preserves_state);
1519 set_flag(CanTrapFlag, cantrap); 1548 set_flag(CanTrapFlag, cantrap);
1535 1564
1536 bool has_receiver() const { return (_recv != NULL); } 1565 bool has_receiver() const { return (_recv != NULL); }
1537 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } 1566 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; }
1538 bool preserves_state() const { return check_flag(PreservesStateFlag); } 1567 bool preserves_state() const { return check_flag(PreservesStateFlag); }
1539 1568
1540 bool arg_needs_null_check(int i) { 1569 bool arg_needs_null_check(int i) const {
1541 if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1570 return _nonnull_state.arg_needs_null_check(i);
1542 return is_set_nth_bit(_nonnull_state, i);
1543 }
1544 return true;
1545 } 1571 }
1546 1572
1547 void set_arg_needs_null_check(int i, bool check) { 1573 void set_arg_needs_null_check(int i, bool check) {
1548 if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1574 _nonnull_state.set_arg_needs_null_check(i, check);
1549 if (check) {
1550 _nonnull_state |= nth_bit(i);
1551 } else {
1552 _nonnull_state &= ~(nth_bit(i));
1553 }
1554 }
1555 } 1575 }
1556 1576
1557 // generic 1577 // generic
1558 virtual bool can_trap() const { return check_flag(CanTrapFlag); } 1578 virtual bool can_trap() const { return check_flag(CanTrapFlag); }
1559 virtual void input_values_do(ValueVisitor* f) { 1579 virtual void input_values_do(ValueVisitor* f) {
2448 } 2468 }
2449 }; 2469 };
2450 2470
2451 LEAF(ProfileCall, Instruction) 2471 LEAF(ProfileCall, Instruction)
2452 private: 2472 private:
2453 ciMethod* _method; 2473 ciMethod* _method;
2454 int _bci_of_invoke; 2474 int _bci_of_invoke;
2455 ciMethod* _callee; // the method that is called at the given bci 2475 ciMethod* _callee; // the method that is called at the given bci
2456 Value _recv; 2476 Value _recv;
2457 ciKlass* _known_holder; 2477 ciKlass* _known_holder;
2458 2478 Values* _obj_args; // arguments for type profiling
2459 public: 2479 ArgsNonNullState _nonnull_state; // Do we know whether some arguments are never null?
2460 ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder) 2480 bool _inlined; // Are we profiling a call that is inlined
2481
2482 public:
2483 ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined)
2461 : Instruction(voidType) 2484 : Instruction(voidType)
2462 , _method(method) 2485 , _method(method)
2463 , _bci_of_invoke(bci) 2486 , _bci_of_invoke(bci)
2464 , _callee(callee) 2487 , _callee(callee)
2465 , _recv(recv) 2488 , _recv(recv)
2466 , _known_holder(known_holder) 2489 , _known_holder(known_holder)
2490 , _obj_args(obj_args)
2491 , _inlined(inlined)
2467 { 2492 {
2468 // The ProfileCall has side-effects and must occur precisely where located 2493 // The ProfileCall has side-effects and must occur precisely where located
2469 pin(); 2494 pin();
2470 } 2495 }
2471 2496
2472 ciMethod* method() { return _method; } 2497 ciMethod* method() const { return _method; }
2473 int bci_of_invoke() { return _bci_of_invoke; } 2498 int bci_of_invoke() const { return _bci_of_invoke; }
2474 ciMethod* callee() { return _callee; } 2499 ciMethod* callee() const { return _callee; }
2475 Value recv() { return _recv; } 2500 Value recv() const { return _recv; }
2476 ciKlass* known_holder() { return _known_holder; } 2501 ciKlass* known_holder() const { return _known_holder; }
2477 2502 int nb_profiled_args() const { return _obj_args == NULL ? 0 : _obj_args->length(); }
2478 virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } 2503 Value profiled_arg_at(int i) const { return _obj_args->at(i); }
2479 }; 2504 bool arg_needs_null_check(int i) const {
2480 2505 return _nonnull_state.arg_needs_null_check(i);
2506 }
2507 bool inlined() const { return _inlined; }
2508
2509 void set_arg_needs_null_check(int i, bool check) {
2510 _nonnull_state.set_arg_needs_null_check(i, check);
2511 }
2512
2513 virtual void input_values_do(ValueVisitor* f) {
2514 if (_recv != NULL) {
2515 f->visit(&_recv);
2516 }
2517 for (int i = 0; i < nb_profiled_args(); i++) {
2518 f->visit(_obj_args->adr_at(i));
2519 }
2520 }
2521 };
2522
2523 LEAF(ProfileReturnType, Instruction)
2524 private:
2525 ciMethod* _method;
2526 ciMethod* _callee;
2527 int _bci_of_invoke;
2528 Value _ret;
2529
2530 public:
2531 ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2532 : Instruction(voidType)
2533 , _method(method)
2534 , _callee(callee)
2535 , _bci_of_invoke(bci)
2536 , _ret(ret)
2537 {
2538 set_needs_null_check(true);
2539 // The ProfileType has side-effects and must occur precisely where located
2540 pin();
2541 }
2542
2543 ciMethod* method() const { return _method; }
2544 ciMethod* callee() const { return _callee; }
2545 int bci_of_invoke() const { return _bci_of_invoke; }
2546 Value ret() const { return _ret; }
2547
2548 virtual void input_values_do(ValueVisitor* f) {
2549 if (_ret != NULL) {
2550 f->visit(&_ret);
2551 }
2552 }
2553 };
2481 2554
2482 // Call some C runtime function that doesn't safepoint, 2555 // Call some C runtime function that doesn't safepoint,
2483 // optionally passing the current thread as the first argument. 2556 // optionally passing the current thread as the first argument.
2484 LEAF(RuntimeCall, Instruction) 2557 LEAF(RuntimeCall, Instruction)
2485 private: 2558 private: