/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "ArrayProfile.h"
#include "CodeBlock.h"
+#include "JSCInlines.h"
+#include <wtf/CommaPrinter.h>
#include <wtf/StringExtras.h>
#include <wtf/StringPrintStream.h>
void dumpArrayModes(PrintStream& out, ArrayModes arrayModes)
{
if (!arrayModes) {
- out.print("0:<empty>");
+ out.print("<empty>");
return;
}
return;
}
- out.print(arrayModes, ":");
-
+ CommaPrinter comma("|");
if (arrayModes & asArrayModes(NonArray))
- out.print("NonArray");
+ out.print(comma, "NonArray");
if (arrayModes & asArrayModes(NonArrayWithInt32))
- out.print("NonArrayWithInt32");
+ out.print(comma, "NonArrayWithInt32");
if (arrayModes & asArrayModes(NonArrayWithDouble))
- out.print("NonArrayWithDouble");
+ out.print(comma, "NonArrayWithDouble");
if (arrayModes & asArrayModes(NonArrayWithContiguous))
- out.print("NonArrayWithContiguous");
+ out.print(comma, "NonArrayWithContiguous");
if (arrayModes & asArrayModes(NonArrayWithArrayStorage))
- out.print("NonArrayWithArrayStorage");
+ out.print(comma, "NonArrayWithArrayStorage");
if (arrayModes & asArrayModes(NonArrayWithSlowPutArrayStorage))
- out.print("NonArrayWithSlowPutArrayStorage");
+ out.print(comma, "NonArrayWithSlowPutArrayStorage");
if (arrayModes & asArrayModes(ArrayClass))
- out.print("ArrayClass");
+ out.print(comma, "ArrayClass");
if (arrayModes & asArrayModes(ArrayWithUndecided))
- out.print("ArrayWithUndecided");
+ out.print(comma, "ArrayWithUndecided");
if (arrayModes & asArrayModes(ArrayWithInt32))
- out.print("ArrayWithInt32");
+ out.print(comma, "ArrayWithInt32");
if (arrayModes & asArrayModes(ArrayWithDouble))
- out.print("ArrayWithDouble");
+ out.print(comma, "ArrayWithDouble");
if (arrayModes & asArrayModes(ArrayWithContiguous))
- out.print("ArrayWithContiguous");
+ out.print(comma, "ArrayWithContiguous");
if (arrayModes & asArrayModes(ArrayWithArrayStorage))
- out.print("ArrayWithArrayStorage");
+ out.print(comma, "ArrayWithArrayStorage");
if (arrayModes & asArrayModes(ArrayWithSlowPutArrayStorage))
- out.print("ArrayWithSlowPutArrayStorage");
+ out.print(comma, "ArrayWithSlowPutArrayStorage");
+
+ if (arrayModes & Int8ArrayMode)
+ out.print(comma, "Int8ArrayMode");
+ if (arrayModes & Int16ArrayMode)
+ out.print(comma, "Int16ArrayMode");
+ if (arrayModes & Int32ArrayMode)
+ out.print(comma, "Int32ArrayMode");
+ if (arrayModes & Uint8ArrayMode)
+ out.print(comma, "Uint8ArrayMode");
+ if (arrayModes & Uint8ClampedArrayMode)
+ out.print(comma, "Uint8ClampedArrayMode");
+ if (arrayModes & Uint16ArrayMode)
+ out.print(comma, "Uint16ArrayMode");
+ if (arrayModes & Uint32ArrayMode)
+ out.print(comma, "Uint32ArrayMode");
+ if (arrayModes & Float32ArrayMode)
+ out.print(comma, "Float32ArrayMode");
+ if (arrayModes & Float64ArrayMode)
+ out.print(comma, "Float64ArrayMode");
}
-ArrayModes ArrayProfile::updatedObservedArrayModes() const
+void ArrayProfile::computeUpdatedPrediction(const ConcurrentJITLocker& locker, CodeBlock* codeBlock)
{
- if (m_lastSeenStructure)
- return m_observedArrayModes | arrayModeFromStructure(m_lastSeenStructure);
- return m_observedArrayModes;
+ if (!m_lastSeenStructureID)
+ return;
+
+ Structure* lastSeenStructure = codeBlock->heap()->structureIDTable().get(m_lastSeenStructureID);
+ computeUpdatedPrediction(locker, codeBlock, lastSeenStructure);
+ m_lastSeenStructureID = 0;
}
-void ArrayProfile::computeUpdatedPrediction(CodeBlock* codeBlock, OperationInProgress operation)
+void ArrayProfile::computeUpdatedPrediction(const ConcurrentJITLocker&, CodeBlock* codeBlock, Structure* lastSeenStructure)
{
- const bool verbose = false;
-
- if (m_lastSeenStructure) {
- m_observedArrayModes |= arrayModeFromStructure(m_lastSeenStructure);
- m_mayInterceptIndexedAccesses |=
- m_lastSeenStructure->typeInfo().interceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero();
- if (!codeBlock->globalObject()->isOriginalArrayStructure(m_lastSeenStructure))
- m_usesOriginalArrayStructures = false;
- if (!structureIsPolymorphic()) {
- if (!m_expectedStructure)
- m_expectedStructure = m_lastSeenStructure;
- else if (m_expectedStructure != m_lastSeenStructure) {
- if (verbose)
- dataLog(*codeBlock, " bc#", m_bytecodeOffset, ": making structure polymorphic because ", RawPointer(m_expectedStructure), " (", m_expectedStructure->classInfo()->className, ") != ", RawPointer(m_lastSeenStructure), " (", m_lastSeenStructure->classInfo()->className, ")\n");
- m_expectedStructure = polymorphicStructure();
- }
- }
- m_lastSeenStructure = 0;
- }
+ m_observedArrayModes |= arrayModeFromStructure(lastSeenStructure);
- if (hasTwoOrMoreBitsSet(m_observedArrayModes)) {
- if (verbose)
- dataLog(*codeBlock, " bc#", m_bytecodeOffset, ": making structure polymorphic because two or more bits are set in m_observedArrayModes\n");
- m_expectedStructure = polymorphicStructure();
+ if (!m_didPerformFirstRunPruning
+ && hasTwoOrMoreBitsSet(m_observedArrayModes)) {
+ m_observedArrayModes = arrayModeFromStructure(lastSeenStructure);
+ m_didPerformFirstRunPruning = true;
}
- if (operation == Collection
- && expectedStructure()
- && !Heap::isMarked(m_expectedStructure)) {
- if (verbose)
- dataLog(*codeBlock, " bc#", m_bytecodeOffset, ": making structure during GC\n");
- m_expectedStructure = polymorphicStructure();
- }
+ m_mayInterceptIndexedAccesses |=
+ lastSeenStructure->typeInfo().interceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero();
+ JSGlobalObject* globalObject = codeBlock->globalObject();
+ if (!globalObject->isOriginalArrayStructure(lastSeenStructure)
+ && !globalObject->isOriginalTypedArrayStructure(lastSeenStructure))
+ m_usesOriginalArrayStructures = false;
}
-CString ArrayProfile::briefDescription(CodeBlock* codeBlock)
+CString ArrayProfile::briefDescription(const ConcurrentJITLocker& locker, CodeBlock* codeBlock)
+{
+ computeUpdatedPrediction(locker, codeBlock);
+ return briefDescriptionWithoutUpdating(locker);
+}
+
+CString ArrayProfile::briefDescriptionWithoutUpdating(const ConcurrentJITLocker&)
{
- computeUpdatedPrediction(codeBlock);
-
StringPrintStream out;
bool hasPrinted = false;
hasPrinted = true;
}
- if (structureIsPolymorphic()) {
- if (hasPrinted)
- out.print(", ");
- out.print("struct = TOP");
- hasPrinted = true;
- } else if (m_expectedStructure) {
- if (hasPrinted)
- out.print(", ");
- out.print("struct = ", RawPointer(m_expectedStructure));
- hasPrinted = true;
- }
-
if (m_mayStoreToHole) {
if (hasPrinted)
out.print(", ");