|
41 | 41 | package com.oracle.truffle.js.nodes.access; |
42 | 42 |
|
43 | 43 | import java.io.PrintStream; |
| 44 | +import java.util.Arrays; |
44 | 45 | import java.util.Locale; |
45 | 46 | import java.util.concurrent.locks.Lock; |
46 | 47 |
|
@@ -338,9 +339,13 @@ static AbstractShapeCheckNode create(Shape shape, JSDynamicObject thisObj, Objec |
338 | 339 | ass[pos++] = shape.getValidAssumption(); |
339 | 340 | JSDynamicObject finalProto = JSObject.getPrototype(thisObj); |
340 | 341 | Shape protoShape = finalProto.getShape(); |
341 | | - ass[pos++] = protoShape.getValidAssumption(); |
342 | | - ass[pos++] = JSShape.getPropertyAssumption(protoShape, key, true); |
343 | | - assert pos == ass.length; |
| 342 | + if (finalProto != Null.instance) { |
| 343 | + ass[pos++] = protoShape.getValidAssumption(); |
| 344 | + ass[pos++] = JSShape.getPropertyAssumption(protoShape, key, true); |
| 345 | + } |
| 346 | + if (pos != ass.length) { |
| 347 | + ass = Arrays.copyOfRange(ass, 0, pos); |
| 348 | + } |
344 | 349 | return new PrototypeShapeCheckNode(shape, ass, finalProto, context); |
345 | 350 | } |
346 | 351 |
|
@@ -368,15 +373,19 @@ static AbstractShapeCheckNode create(Shape shape, JSDynamicObject thisObj, Objec |
368 | 373 | JSDynamicObject depthProto = thisObj; |
369 | 374 | for (int i = 0; i < depth; i++) { |
370 | 375 | Assumption stablePrototypeAssumption = i == 0 ? null : JSShape.getPrototypeAssumption(depthShape); |
371 | | - depthProto = JSObject.getPrototype(depthProto); |
372 | | - depthShape = depthProto.getShape(); |
373 | | - ass[pos++] = depthShape.getValidAssumption(); |
374 | | - ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
375 | 376 | if (stablePrototypeAssumption != null) { |
376 | 377 | ass[pos++] = stablePrototypeAssumption; |
377 | 378 | } |
| 379 | + depthProto = JSObject.getPrototype(depthProto); |
| 380 | + depthShape = depthProto.getShape(); |
| 381 | + if (depthProto != Null.instance) { |
| 382 | + ass[pos++] = depthShape.getValidAssumption(); |
| 383 | + ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
| 384 | + } |
| 385 | + } |
| 386 | + if (pos != ass.length) { |
| 387 | + ass = Arrays.copyOfRange(ass, 0, pos); |
378 | 388 | } |
379 | | - assert pos == ass.length; |
380 | 389 | return new PrototypeChainShapeCheckNode(shape, ass, depthProto, context); |
381 | 390 | } |
382 | 391 |
|
@@ -457,13 +466,17 @@ static AbstractShapeCheckNode create(Shape shape, JSDynamicObject thisObj, Objec |
457 | 466 | JSDynamicObject depthProto = thisObj; |
458 | 467 | for (int i = 0; i < depth; i++) { |
459 | 468 | Assumption stablePrototypeAssumption = JSShape.getPrototypeAssumption(depthShape); |
| 469 | + ass[pos++] = stablePrototypeAssumption; |
460 | 470 | depthProto = JSObject.getPrototype(depthProto); |
461 | 471 | depthShape = depthProto.getShape(); |
462 | | - ass[pos++] = depthShape.getValidAssumption(); |
463 | | - ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
464 | | - ass[pos++] = stablePrototypeAssumption; |
| 472 | + if (depthProto != Null.instance) { |
| 473 | + ass[pos++] = depthShape.getValidAssumption(); |
| 474 | + ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
| 475 | + } |
| 476 | + } |
| 477 | + if (pos != ass.length) { |
| 478 | + ass = Arrays.copyOfRange(ass, 0, pos); |
465 | 479 | } |
466 | | - assert pos == ass.length; |
467 | 480 | return new ConstantObjectPrototypeChainShapeCheckNode(shape, ass, depthProto, context); |
468 | 481 | } |
469 | 482 |
|
@@ -653,15 +666,19 @@ static AbstractShapeCheckNode create(Class<?> valueClass, Shape shape, JSDynamic |
653 | 666 | JSDynamicObject depthProto = thisObj; |
654 | 667 | for (int i = 0; i < depth; i++) { |
655 | 668 | Assumption stablePrototypeAssumption = i == 0 ? null : JSShape.getPrototypeAssumption(depthShape); |
656 | | - depthProto = JSObject.getPrototype(depthProto); |
657 | | - depthShape = depthProto.getShape(); |
658 | | - ass[pos++] = depthShape.getValidAssumption(); |
659 | | - ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
660 | 669 | if (stablePrototypeAssumption != null) { |
661 | 670 | ass[pos++] = stablePrototypeAssumption; |
662 | 671 | } |
| 672 | + depthProto = JSObject.getPrototype(depthProto); |
| 673 | + depthShape = depthProto.getShape(); |
| 674 | + if (depthProto != Null.instance) { |
| 675 | + ass[pos++] = depthShape.getValidAssumption(); |
| 676 | + ass[pos++] = JSShape.getPropertyAssumption(depthShape, key, true); |
| 677 | + } |
| 678 | + } |
| 679 | + if (pos != ass.length) { |
| 680 | + ass = Arrays.copyOfRange(ass, 0, pos); |
663 | 681 | } |
664 | | - assert pos == ass.length; |
665 | 682 | return new ValuePrototypeChainCheckNode(valueClass, shape, ass, depthProto, context); |
666 | 683 | } |
667 | 684 |
|
|
0 commit comments