diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGArrayMode.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGArrayMode.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGArrayMode.h | 91 |
1 files changed, 63 insertions, 28 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGArrayMode.h b/Source/JavaScriptCore/dfg/DFGArrayMode.h index cbb87bd93..45e1d5a12 100644 --- a/Source/JavaScriptCore/dfg/DFGArrayMode.h +++ b/Source/JavaScriptCore/dfg/DFGArrayMode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2012-2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DFGArrayMode_h -#define DFGArrayMode_h - -#include <wtf/Platform.h> +#pragma once #if ENABLE(DFG_JIT) @@ -55,6 +52,7 @@ enum Action { enum Type { SelectUsingPredictions, // Implies that we need predictions to decide. We will never get to the backend in this mode. + SelectUsingArguments, // Implies that we use the Node's arguments to decide. We will never get to the backend in this mode. Unprofiled, // Implies that array profiling didn't see anything. But that could be because the operands didn't comply with basic type assumptions (base is cell, property is int). This either becomes Generic or ForceExit depending on value profiling. ForceExit, // Implies that we have no idea how to execute this operation, so we should just give up. Generic, @@ -67,7 +65,9 @@ enum Type { ArrayStorage, SlowPutArrayStorage, - Arguments, + DirectArguments, + ScopedArguments, + Int8Array, Int16Array, Int32Array, @@ -76,7 +76,8 @@ enum Type { Uint16Array, Uint32Array, Float32Array, - Float64Array + Float64Array, + AnyTypedArray }; enum Class { @@ -89,14 +90,14 @@ enum Class { enum Speculation { SaneChain, // In bounds and the array prototype chain is still intact, i.e. loading a hole doesn't require special treatment. + InBounds, // In bounds and not loading a hole. ToHole, // Potentially storing to a hole. OutOfBounds // Out-of-bounds access and anything can happen. }; enum Conversion { AsIs, - Convert, - RageConvert + Convert }; } // namespace Array @@ -109,6 +110,7 @@ IndexingType toIndexingShape(Array::Type); TypedArrayType toTypedArrayType(Array::Type); Array::Type toArrayType(TypedArrayType); +Array::Type refineTypedArrayType(Array::Type, TypedArrayType); bool permitsBoundsCheckLowering(Array::Type); @@ -166,18 +168,22 @@ public: return ArrayMode(word); } - static ArrayMode fromObserved(const ConcurrentJITLocker&, ArrayProfile*, Array::Action, bool makeSafe); + static ArrayMode fromObserved(const ConcurrentJSLocker&, ArrayProfile*, Array::Action, bool makeSafe); ArrayMode withSpeculation(Array::Speculation speculation) const { return ArrayMode(type(), arrayClass(), speculation, conversion()); } - ArrayMode withProfile(const ConcurrentJITLocker& locker, ArrayProfile* profile, bool makeSafe) const + ArrayMode withArrayClass(Array::Class arrayClass) const + { + return ArrayMode(type(), arrayClass, speculation(), conversion()); + } + + ArrayMode withSpeculationFromProfile(const ConcurrentJSLocker& locker, ArrayProfile* profile, bool makeSafe) const { Array::Speculation mySpeculation; - Array::Class myArrayClass; - + if (makeSafe) mySpeculation = Array::OutOfBounds; else if (profile->mayStoreToHole(locker)) @@ -185,6 +191,13 @@ public: else mySpeculation = Array::InBounds; + return withSpeculation(mySpeculation); + } + + ArrayMode withProfile(const ConcurrentJSLocker& locker, ArrayProfile* profile, bool makeSafe) const + { + Array::Class myArrayClass; + if (isJSArray()) { if (profile->usesOriginalArrayStructures(locker) && benefitsFromOriginalArray()) myArrayClass = Array::OriginalArray; @@ -193,7 +206,7 @@ public: } else myArrayClass = arrayClass(); - return ArrayMode(type(), myArrayClass, mySpeculation, conversion()); + return withArrayClass(myArrayClass).withSpeculationFromProfile(locker, profile, makeSafe); } ArrayMode withType(Array::Type type) const @@ -211,15 +224,16 @@ public: return ArrayMode(type, arrayClass(), speculation(), conversion); } - ArrayMode refine(SpeculatedType base, SpeculatedType index, SpeculatedType value = SpecNone, NodeFlags = 0) const; + ArrayMode refine(Graph&, Node*, SpeculatedType base, SpeculatedType index, SpeculatedType value = SpecNone) const; - bool alreadyChecked(Graph&, Node*, AbstractValue&) const; + bool alreadyChecked(Graph&, Node*, const AbstractValue&) const; void dump(PrintStream&) const; bool usesButterfly() const { switch (type()) { + case Array::Undecided: case Array::Int32: case Array::Double: case Array::Contiguous: @@ -282,10 +296,13 @@ public: { switch (type()) { case Array::SelectUsingPredictions: + case Array::SelectUsingArguments: case Array::Unprofiled: + case Array::Undecided: case Array::ForceExit: case Array::Generic: - case Array::Arguments: + case Array::DirectArguments: + case Array::ScopedArguments: return false; default: return true; @@ -311,11 +328,9 @@ public: { switch (type()) { case Array::String: + case Array::DirectArguments: + case Array::ScopedArguments: return ArrayMode(Array::Generic); -#if USE(JSVALUE32_64) - case Array::Arguments: - return ArrayMode(Array::Generic); -#endif default: return *this; } @@ -325,23 +340,33 @@ public: { switch (type()) { case Array::SelectUsingPredictions: + case Array::SelectUsingArguments: case Array::Unprofiled: case Array::ForceExit: case Array::Generic: - case Array::Undecided: return false; default: return true; } } - bool supportsLength() const + bool supportsSelfLength() const { switch (type()) { case Array::SelectUsingPredictions: case Array::Unprofiled: case Array::ForceExit: case Array::Generic: + // TypedArrays do not have a self length property as of ES6. + case Array::Int8Array: + case Array::Int16Array: + case Array::Int32Array: + case Array::Uint8Array: + case Array::Uint8ClampedArray: + case Array::Uint16Array: + case Array::Uint32Array: + case Array::Float32Array: + case Array::Float64Array: return false; case Array::Int32: case Array::Double: @@ -362,6 +387,7 @@ public: case Array::Int32: case Array::Double: case Array::Contiguous: + case Array::Undecided: case Array::ArrayStorage: return true; default: @@ -397,7 +423,7 @@ public: case Array::ArrayStorage: return arrayModesWithIndexingShape(ArrayStorageShape); case Array::SlowPutArrayStorage: - return arrayModesWithIndexingShape(SlowPutArrayStorageShape); + return arrayModesWithIndexingShapes(SlowPutArrayStorageShape, ArrayStorageShape); default: return asArrayModes(NonArray); } @@ -417,6 +443,11 @@ public: { return toTypedArrayType(type()); } + + bool isSomeTypedArrayView() const + { + return type() == Array::AnyTypedArray || isTypedView(typedArrayType()); + } bool operator==(const ArrayMode& other) const { @@ -453,7 +484,14 @@ private: } } - bool alreadyChecked(Graph&, Node*, AbstractValue&, IndexingType shape) const; + ArrayModes arrayModesWithIndexingShapes(IndexingType shape1, IndexingType shape2) const + { + ArrayModes arrayMode1 = arrayModesWithIndexingShape(shape1); + ArrayModes arrayMode2 = arrayModesWithIndexingShape(shape2); + return arrayMode1 | arrayMode2; + } + + bool alreadyChecked(Graph&, Node*, const AbstractValue&, IndexingType shape) const; union { struct { @@ -494,6 +532,3 @@ void printInternal(PrintStream&, JSC::DFG::Array::Conversion); } // namespace WTF #endif // ENABLE(DFG_JIT) - -#endif // DFGArrayMode_h - |