comparison graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java @ 7530:5e3d1a68664e

applied mx eclipseformat to all Java files
author Doug Simon <doug.simon@oracle.com>
date Wed, 23 Jan 2013 16:34:57 +0100
parents d79098b9db3b
children 4e1278443941
comparison
equal deleted inserted replaced
7529:4a11124a3563 7530:5e3d1a68664e
205 private void propagateDelete(FloatingNode node) { 205 private void propagateDelete(FloatingNode node) {
206 assert node instanceof PhiNode || node instanceof ValueProxyNode; 206 assert node instanceof PhiNode || node instanceof ValueProxyNode;
207 if (node.isDeleted()) { 207 if (node.isDeleted()) {
208 return; 208 return;
209 } 209 }
210 // Collect all phi functions that use this phi so that we can delete them recursively (after we delete ourselves to avoid circles). 210 // Collect all phi functions that use this phi so that we can delete them recursively (after
211 // we delete ourselves to avoid circles).
211 List<FloatingNode> propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(PhiNode.class).or(ValueProxyNode.class)).snapshot(); 212 List<FloatingNode> propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(PhiNode.class).or(ValueProxyNode.class)).snapshot();
212 213
213 // Remove the phi function from all FrameStates where it is used and then delete it. 214 // Remove the phi function from all FrameStates where it is used and then delete it.
214 assert node.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ValueProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; 215 assert node.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ValueProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states";
215 node.replaceAtUsages(null); 216 node.replaceAtUsages(null);
314 315
315 public void setRethrowException(boolean b) { 316 public void setRethrowException(boolean b) {
316 rethrowException = b; 317 rethrowException = b;
317 } 318 }
318 319
319
320 /** 320 /**
321 * Returns the size of the local variables. 321 * Returns the size of the local variables.
322 * 322 *
323 * @return the size of the local variables 323 * @return the size of the local variables
324 */ 324 */
325 public int localsSize() { 325 public int localsSize() {
326 return locals.length; 326 return locals.length;
327 } 327 }
333 return stackSize; 333 return stackSize;
334 } 334 }
335 335
336 /** 336 /**
337 * Gets the value in the local variables at the specified index, without any sanity checking. 337 * Gets the value in the local variables at the specified index, without any sanity checking.
338 * 338 *
339 * @param i the index into the locals 339 * @param i the index into the locals
340 * @return the instruction that produced the value for the specified local 340 * @return the instruction that produced the value for the specified local
341 */ 341 */
342 public final ValueNode localAt(int i) { 342 public final ValueNode localAt(int i) {
343 return locals[i]; 343 return locals[i];
344 } 344 }
345 345
346 /** 346 /**
347 * Get the value on the stack at the specified stack index. 347 * Get the value on the stack at the specified stack index.
348 * 348 *
349 * @param i the index into the stack, with {@code 0} being the bottom of the stack 349 * @param i the index into the stack, with {@code 0} being the bottom of the stack
350 * @return the instruction at the specified position in the stack 350 * @return the instruction at the specified position in the stack
351 */ 351 */
352 public final ValueNode stackAt(int i) { 352 public final ValueNode stackAt(int i) {
353 return stack[i]; 353 return stack[i];
354 } 354 }
355 355
356 /** 356 /**
357 * Adds a locked monitor to this frame state. 357 * Adds a locked monitor to this frame state.
358 * 358 *
359 * @param object the object whose monitor will be locked. 359 * @param object the object whose monitor will be locked.
360 */ 360 */
361 public void pushLock(ValueNode object) { 361 public void pushLock(ValueNode object) {
362 locks = Arrays.copyOf(locks, locks.length + 1); 362 locks = Arrays.copyOf(locks, locks.length + 1);
363 locks[locks.length - 1] = object; 363 locks[locks.length - 1] = object;
364 } 364 }
365 365
366 /** 366 /**
367 * Removes a locked monitor from this frame state. 367 * Removes a locked monitor from this frame state.
368 * 368 *
369 * @return the object whose monitor was removed from the locks list. 369 * @return the object whose monitor was removed from the locks list.
370 */ 370 */
371 public ValueNode popLock() { 371 public ValueNode popLock() {
372 try { 372 try {
373 return locks[locks.length - 1]; 373 return locks[locks.length - 1];
384 } 384 }
385 385
386 /** 386 /**
387 * Loads the local variable at the specified index, checking that the returned value is non-null 387 * Loads the local variable at the specified index, checking that the returned value is non-null
388 * and that two-stack values are properly handled. 388 * and that two-stack values are properly handled.
389 * 389 *
390 * @param i the index of the local variable to load 390 * @param i the index of the local variable to load
391 * @return the instruction that produced the specified local 391 * @return the instruction that produced the specified local
392 */ 392 */
393 public ValueNode loadLocal(int i) { 393 public ValueNode loadLocal(int i) {
394 ValueNode x = locals[i]; 394 ValueNode x = locals[i];
397 assert i == 0 || locals[i - 1] == null || !isTwoSlot(locals[i - 1].kind()); 397 assert i == 0 || locals[i - 1] == null || !isTwoSlot(locals[i - 1].kind());
398 return x; 398 return x;
399 } 399 }
400 400
401 /** 401 /**
402 * Stores a given local variable at the specified index. If the value occupies {@linkplain FrameStateBuilder#isTwoSlot(Kind) two slots}, 402 * Stores a given local variable at the specified index. If the value occupies
403 * then the next local variable index is also overwritten. 403 * {@linkplain FrameStateBuilder#isTwoSlot(Kind) two slots}, then the next local variable index
404 * 404 * is also overwritten.
405 *
405 * @param i the index at which to store 406 * @param i the index at which to store
406 * @param x the instruction which produces the value for the local 407 * @param x the instruction which produces the value for the local
407 */ 408 */
408 public void storeLocal(int i, ValueNode x) { 409 public void storeLocal(int i, ValueNode x) {
409 assert x == null || x.kind() != Kind.Void && x.kind() != Kind.Illegal : "unexpected value: " + x; 410 assert x == null || x.kind() != Kind.Void && x.kind() != Kind.Illegal : "unexpected value: " + x;
426 stack[i] = x; 427 stack[i] = x;
427 } 428 }
428 429
429 /** 430 /**
430 * Pushes an instruction onto the stack with the expected type. 431 * Pushes an instruction onto the stack with the expected type.
432 *
431 * @param kind the type expected for this instruction 433 * @param kind the type expected for this instruction
432 * @param x the instruction to push onto the stack 434 * @param x the instruction to push onto the stack
433 */ 435 */
434 public void push(Kind kind, ValueNode x) { 436 public void push(Kind kind, ValueNode x) {
435 assert !x.isDeleted() && x.kind() != Kind.Void && x.kind() != Kind.Illegal; 437 assert !x.isDeleted() && x.kind() != Kind.Void && x.kind() != Kind.Illegal;
439 } 441 }
440 } 442 }
441 443
442 /** 444 /**
443 * Pushes a value onto the stack without checking the type. 445 * Pushes a value onto the stack without checking the type.
446 *
444 * @param x the instruction to push onto the stack 447 * @param x the instruction to push onto the stack
445 */ 448 */
446 public void xpush(ValueNode x) { 449 public void xpush(ValueNode x) {
447 assert x == null || (!x.isDeleted() && x.kind() != Kind.Void && x.kind() != Kind.Illegal); 450 assert x == null || (!x.isDeleted() && x.kind() != Kind.Void && x.kind() != Kind.Illegal);
448 stack[stackSize++] = x; 451 stack[stackSize++] = x;
449 } 452 }
450 453
451 /** 454 /**
452 * Pushes a value onto the stack and checks that it is an int. 455 * Pushes a value onto the stack and checks that it is an int.
456 *
453 * @param x the instruction to push onto the stack 457 * @param x the instruction to push onto the stack
454 */ 458 */
455 public void ipush(ValueNode x) { 459 public void ipush(ValueNode x) {
456 xpush(assertInt(x)); 460 xpush(assertInt(x));
457 } 461 }
458 462
459 /** 463 /**
460 * Pushes a value onto the stack and checks that it is a float. 464 * Pushes a value onto the stack and checks that it is a float.
465 *
461 * @param x the instruction to push onto the stack 466 * @param x the instruction to push onto the stack
462 */ 467 */
463 public void fpush(ValueNode x) { 468 public void fpush(ValueNode x) {
464 xpush(assertFloat(x)); 469 xpush(assertFloat(x));
465 } 470 }
466 471
467 /** 472 /**
468 * Pushes a value onto the stack and checks that it is an object. 473 * Pushes a value onto the stack and checks that it is an object.
474 *
469 * @param x the instruction to push onto the stack 475 * @param x the instruction to push onto the stack
470 */ 476 */
471 public void apush(ValueNode x) { 477 public void apush(ValueNode x) {
472 xpush(assertObject(x)); 478 xpush(assertObject(x));
473 } 479 }
474 480
475 /** 481 /**
476 * Pushes a value onto the stack and checks that it is a JSR return address. 482 * Pushes a value onto the stack and checks that it is a JSR return address.
483 *
477 * @param x the instruction to push onto the stack 484 * @param x the instruction to push onto the stack
478 */ 485 */
479 public void jpush(ValueNode x) { 486 public void jpush(ValueNode x) {
480 xpush(assertJsr(x)); 487 xpush(assertJsr(x));
481 } 488 }
482 489
483 /** 490 /**
484 * Pushes a value onto the stack and checks that it is a long. 491 * Pushes a value onto the stack and checks that it is a long.
485 * 492 *
486 * @param x the instruction to push onto the stack 493 * @param x the instruction to push onto the stack
487 */ 494 */
488 public void lpush(ValueNode x) { 495 public void lpush(ValueNode x) {
489 xpush(assertLong(x)); 496 xpush(assertLong(x));
490 xpush(null); 497 xpush(null);
491 } 498 }
492 499
493 /** 500 /**
494 * Pushes a value onto the stack and checks that it is a double. 501 * Pushes a value onto the stack and checks that it is a double.
502 *
495 * @param x the instruction to push onto the stack 503 * @param x the instruction to push onto the stack
496 */ 504 */
497 public void dpush(ValueNode x) { 505 public void dpush(ValueNode x) {
498 xpush(assertDouble(x)); 506 xpush(assertDouble(x));
499 xpush(null); 507 xpush(null);
505 } 513 }
506 } 514 }
507 515
508 /** 516 /**
509 * Pops an instruction off the stack with the expected type. 517 * Pops an instruction off the stack with the expected type.
518 *
510 * @param kind the expected type 519 * @param kind the expected type
511 * @return the instruction on the top of the stack 520 * @return the instruction on the top of the stack
512 */ 521 */
513 public ValueNode pop(Kind kind) { 522 public ValueNode pop(Kind kind) {
514 assert kind != Kind.Void; 523 assert kind != Kind.Void;
518 return assertKind(kind, xpop()); 527 return assertKind(kind, xpop());
519 } 528 }
520 529
521 /** 530 /**
522 * Pops a value off of the stack without checking the type. 531 * Pops a value off of the stack without checking the type.
532 *
523 * @return x the instruction popped off the stack 533 * @return x the instruction popped off the stack
524 */ 534 */
525 public ValueNode xpop() { 535 public ValueNode xpop() {
526 ValueNode result = stack[--stackSize]; 536 ValueNode result = stack[--stackSize];
527 assert result == null || !result.isDeleted(); 537 assert result == null || !result.isDeleted();
528 return result; 538 return result;
529 } 539 }
530 540
531 /** 541 /**
532 * Pops a value off of the stack and checks that it is an int. 542 * Pops a value off of the stack and checks that it is an int.
543 *
533 * @return x the instruction popped off the stack 544 * @return x the instruction popped off the stack
534 */ 545 */
535 public ValueNode ipop() { 546 public ValueNode ipop() {
536 return assertInt(xpop()); 547 return assertInt(xpop());
537 } 548 }
538 549
539 /** 550 /**
540 * Pops a value off of the stack and checks that it is a float. 551 * Pops a value off of the stack and checks that it is a float.
552 *
541 * @return x the instruction popped off the stack 553 * @return x the instruction popped off the stack
542 */ 554 */
543 public ValueNode fpop() { 555 public ValueNode fpop() {
544 return assertFloat(xpop()); 556 return assertFloat(xpop());
545 } 557 }
546 558
547 /** 559 /**
548 * Pops a value off of the stack and checks that it is an object. 560 * Pops a value off of the stack and checks that it is an object.
561 *
549 * @return x the instruction popped off the stack 562 * @return x the instruction popped off the stack
550 */ 563 */
551 public ValueNode apop() { 564 public ValueNode apop() {
552 return assertObject(xpop()); 565 return assertObject(xpop());
553 } 566 }
554 567
555 /** 568 /**
556 * Pops a value off of the stack and checks that it is a JSR return address. 569 * Pops a value off of the stack and checks that it is a JSR return address.
570 *
557 * @return x the instruction popped off the stack 571 * @return x the instruction popped off the stack
558 */ 572 */
559 public ValueNode jpop() { 573 public ValueNode jpop() {
560 return assertJsr(xpop()); 574 return assertJsr(xpop());
561 } 575 }
562 576
563 /** 577 /**
564 * Pops a value off of the stack and checks that it is a long. 578 * Pops a value off of the stack and checks that it is a long.
579 *
565 * @return x the instruction popped off the stack 580 * @return x the instruction popped off the stack
566 */ 581 */
567 public ValueNode lpop() { 582 public ValueNode lpop() {
568 assertHigh(xpop()); 583 assertHigh(xpop());
569 return assertLong(xpop()); 584 return assertLong(xpop());
570 } 585 }
571 586
572 /** 587 /**
573 * Pops a value off of the stack and checks that it is a double. 588 * Pops a value off of the stack and checks that it is a double.
589 *
574 * @return x the instruction popped off the stack 590 * @return x the instruction popped off the stack
575 */ 591 */
576 public ValueNode dpop() { 592 public ValueNode dpop() {
577 assertHigh(xpop()); 593 assertHigh(xpop());
578 return assertDouble(xpop()); 594 return assertDouble(xpop());
579 } 595 }
580 596
581 /** 597 /**
582 * Pop the specified number of slots off of this stack and return them as an array of instructions. 598 * Pop the specified number of slots off of this stack and return them as an array of
599 * instructions.
600 *
583 * @return an array containing the arguments off of the stack 601 * @return an array containing the arguments off of the stack
584 */ 602 */
585 public ValueNode[] popArguments(int slotSize, int argSize) { 603 public ValueNode[] popArguments(int slotSize, int argSize) {
586 int base = stackSize - slotSize; 604 int base = stackSize - slotSize;
587 ValueNode[] r = new ValueNode[argSize]; 605 ValueNode[] r = new ValueNode[argSize];
597 return r; 615 return r;
598 } 616 }
599 617
600 /** 618 /**
601 * Peeks an element from the operand stack. 619 * Peeks an element from the operand stack.
602 * @param argumentNumber The number of the argument, relative from the top of the stack (0 = top). 620 *
603 * Long and double arguments only count as one argument, i.e., null-slots are ignored. 621 * @param argumentNumber The number of the argument, relative from the top of the stack (0 =
622 * top). Long and double arguments only count as one argument, i.e., null-slots are
623 * ignored.
604 * @return The peeked argument. 624 * @return The peeked argument.
605 */ 625 */
606 public ValueNode peek(int argumentNumber) { 626 public ValueNode peek(int argumentNumber) {
607 int idx = stackSize() - 1; 627 int idx = stackSize() - 1;
608 for (int i = 0; i < argumentNumber; i++) { 628 for (int i = 0; i < argumentNumber; i++) {