Ignore:
Timestamp:
Apr 27, 2015, 9:16:21 PM (10 years ago)
Author:
[email protected]
Message:

[JSC] Add support for typed arrays to the Array profiling
https://bugs.webkit.org/show_bug.cgi?id=143913

Patch by Benjamin Poulain <[email protected]> on 2015-04-27
Reviewed by Filip Pizlo.

Source/JavaScriptCore:

This patch adds ArrayModes for every typed arrays. Having that information
let us generate better GetByVal and PutByVal when the type speculation
are not good enough.

A typical case where this is useful is any basic block for which the type
of the object is always more restrictive than the speculation (for example,
a basic block gated by a branch only taken for on type).

  • bytecode/ArrayProfile.cpp:

(JSC::dumpArrayModes):

  • bytecode/ArrayProfile.h:

(JSC::arrayModeFromStructure):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::fromObserved):
(JSC::DFG::ArrayMode::refine):
Maintain the refine() semantic. We do not support OutOfBounds access
for GetByVal on typed array.

  • runtime/IndexingType.h:
  • tests/stress/typed-array-get-by-val-profiling.js: Added.

(testArray.testCode):
(testArray):

  • tests/stress/typed-array-put-by-val-profiling.js: Added.

(testArray.testCode):
(testArray):

LayoutTests:

  • js/regress/script-tests/typed-array-get-set-by-val-profiling.js: Added.
  • js/regress/typed-array-get-set-by-val-profiling.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp

    r181993 r183450  
    9898    case asArrayModes(NonArrayWithArrayStorage) | asArrayModes(ArrayWithArrayStorage) | asArrayModes(NonArrayWithSlowPutArrayStorage) | asArrayModes(ArrayWithSlowPutArrayStorage):
    9999        return ArrayMode(Array::SlowPutArrayStorage, Array::PossiblyArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     100    case Int8ArrayMode:
     101        return ArrayMode(Array::Int8Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     102    case Int16ArrayMode:
     103        return ArrayMode(Array::Int16Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     104    case Int32ArrayMode:
     105        return ArrayMode(Array::Int32Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     106    case Uint8ArrayMode:
     107        return ArrayMode(Array::Uint8Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     108    case Uint8ClampedArrayMode:
     109        return ArrayMode(Array::Uint8ClampedArray, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     110    case Uint16ArrayMode:
     111        return ArrayMode(Array::Uint16Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     112    case Uint32ArrayMode:
     113        return ArrayMode(Array::Uint32Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     114    case Float32ArrayMode:
     115        return ArrayMode(Array::Float32Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     116    case Float64ArrayMode:
     117        return ArrayMode(Array::Float64Array, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    100118
    101119    default:
     
    190208            return withConversion(Array::RageConvert);
    191209        return *this;
    192        
     210
     211    case Array::Int8Array:
     212    case Array::Int16Array:
     213    case Array::Int32Array:
     214    case Array::Uint8Array:
     215    case Array::Uint8ClampedArray:
     216    case Array::Uint16Array:
     217    case Array::Uint32Array:
     218    case Array::Float32Array:
     219    case Array::Float64Array:
     220        switch (node->op()) {
     221        case PutByVal:
     222            if (graph.hasExitSite(node->origin.semantic, OutOfBounds) || !isInBounds())
     223                return withSpeculation(Array::OutOfBounds);
     224            return withSpeculation(Array::InBounds);
     225        default:
     226            return withSpeculation(Array::InBounds);
     227        }
     228        return *this;
    193229    case Array::Unprofiled:
    194230    case Array::SelectUsingPredictions: {
Note: See TracChangeset for help on using the changeset viewer.