110 // We know that our LexicalContext is empty outside the call to functionNode.accept(this) below, |
110 // We know that our LexicalContext is empty outside the call to functionNode.accept(this) below, |
111 // so we can pass null to all methods expecting a LexicalContext parameter. |
111 // so we can pass null to all methods expecting a LexicalContext parameter. |
112 assert lc.isEmpty() : "LexicalContext not empty"; |
112 assert lc.isEmpty() : "LexicalContext not empty"; |
113 |
113 |
114 if (weight >= SPLIT_THRESHOLD) { |
114 if (weight >= SPLIT_THRESHOLD) { |
115 log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); |
115 log.info("Splitting function '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); |
116 functionNode = (FunctionNode)functionNode.accept(this); |
116 functionNode = (FunctionNode)functionNode.accept(this); |
117 |
117 |
118 if (functionNode.isSplit()) { |
118 if (functionNode.isSplit()) { |
119 // Weight has changed so weigh again, this time using block weight cache |
119 // Weight has changed so weigh again, this time using block weight cache |
120 weight = WeighNodes.weigh(functionNode, weightCache); |
120 weight = WeighNodes.weigh(functionNode, weightCache); |
308 |
308 |
309 for (int i = 0; i < postsets.length; i++) { |
309 for (int i = 0; i < postsets.length; i++) { |
310 final int postset = postsets[i]; |
310 final int postset = postsets[i]; |
311 final Node element = value[postset]; |
311 final Node element = value[postset]; |
312 |
312 |
313 weight = WeighNodes.weigh(element); |
313 final long elementWeight = WeighNodes.weigh(element); |
314 totalWeight += WeighNodes.AASTORE_WEIGHT + weight; |
314 totalWeight += WeighNodes.AASTORE_WEIGHT + elementWeight; |
315 |
315 |
316 if (totalWeight >= SPLIT_THRESHOLD) { |
316 if (totalWeight >= SPLIT_THRESHOLD) { |
317 final CompileUnit unit = compiler.findUnit(totalWeight - weight); |
317 final CompileUnit unit = compiler.findUnit(totalWeight - elementWeight); |
318 ranges.add(new Splittable.SplitRange(unit, lo, i)); |
318 ranges.add(new Splittable.SplitRange(unit, lo, i)); |
319 lo = i; |
319 lo = i; |
320 totalWeight = weight; |
320 totalWeight = elementWeight; |
321 } |
321 } |
322 } |
322 } |
323 |
323 |
324 if (lo != postsets.length) { |
324 if (lo != postsets.length) { |
325 final CompileUnit unit = compiler.findUnit(totalWeight); |
325 final CompileUnit unit = compiler.findUnit(totalWeight); |
326 ranges.add(new Splittable.SplitRange(unit, lo, postsets.length)); |
326 ranges.add(new Splittable.SplitRange(unit, lo, postsets.length)); |
327 } |
327 } |
328 |
328 |
|
329 log.info("Splitting array literal in '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); |
|
330 |
329 return arrayLiteralNode.setSplitRanges(lc, ranges); |
331 return arrayLiteralNode.setSplitRanges(lc, ranges); |
330 } |
332 } |
331 |
333 |
332 return literal; |
334 return literal; |
333 } |
335 } |
334 |
336 |
335 @Override |
337 @Override |
336 public Node leaveObjectNode(final ObjectNode objectNode) { |
338 public Node leaveObjectNode(final ObjectNode objectNode) { |
337 long weight = WeighNodes.weigh(objectNode); |
339 final long weight = WeighNodes.weigh(objectNode); |
338 |
340 |
339 if (weight < SPLIT_THRESHOLD) { |
341 if (weight < SPLIT_THRESHOLD) { |
340 return objectNode; |
342 return objectNode; |
341 } |
343 } |
342 |
344 |
353 |
355 |
354 final PropertyNode property = properties.get(i); |
356 final PropertyNode property = properties.get(i); |
355 final boolean isConstant = LiteralNode.isConstant(property.getValue()); |
357 final boolean isConstant = LiteralNode.isConstant(property.getValue()); |
356 |
358 |
357 if (!isConstant || !isSpillObject) { |
359 if (!isConstant || !isSpillObject) { |
358 weight = isConstant ? 0 : WeighNodes.weigh(property.getValue()); |
360 final long propertyWeight = isConstant ? 0 : WeighNodes.weigh(property.getValue()); |
359 totalWeight += WeighNodes.AASTORE_WEIGHT + weight; |
361 totalWeight += WeighNodes.AASTORE_WEIGHT + propertyWeight; |
360 |
362 |
361 if (totalWeight >= SPLIT_THRESHOLD) { |
363 if (totalWeight >= SPLIT_THRESHOLD) { |
362 final CompileUnit unit = compiler.findUnit(totalWeight - weight); |
364 final CompileUnit unit = compiler.findUnit(totalWeight - propertyWeight); |
363 ranges.add(new Splittable.SplitRange(unit, lo, i)); |
365 ranges.add(new Splittable.SplitRange(unit, lo, i)); |
364 lo = i; |
366 lo = i; |
365 totalWeight = weight; |
367 totalWeight = propertyWeight; |
366 } |
368 } |
367 } |
369 } |
368 } |
370 } |
369 |
371 |
370 if (lo != properties.size()) { |
372 if (lo != properties.size()) { |
371 final CompileUnit unit = compiler.findUnit(totalWeight); |
373 final CompileUnit unit = compiler.findUnit(totalWeight); |
372 ranges.add(new Splittable.SplitRange(unit, lo, properties.size())); |
374 ranges.add(new Splittable.SplitRange(unit, lo, properties.size())); |
373 } |
375 } |
374 |
376 |
|
377 log.info("Splitting object node in '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD); |
|
378 |
375 return objectNode.setSplitRanges(lc, ranges); |
379 return objectNode.setSplitRanges(lc, ranges); |
376 } |
380 } |
377 |
381 |
378 @Override |
382 @Override |
379 public boolean enterFunctionNode(final FunctionNode node) { |
383 public boolean enterFunctionNode(final FunctionNode node) { |