v8/src/builtins/base.tq

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1368 lines
51 KiB
Plaintext
Raw Normal View History

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-utils-gen.h'
#include 'src/builtins/builtins.h'
#include 'src/code-factory.h'
#include 'src/elements-kind.h'
#include 'src/heap/factory-inl.h'
#include 'src/objects.h'
#include 'src/objects/arguments.h'
#include 'src/objects/bigint.h'
type Arguments constexpr 'CodeStubArguments*';
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
type void;
type never;
type Tagged generates 'TNode<Object>' constexpr 'ObjectPtr';
type Smi extends Tagged generates 'TNode<Smi>' constexpr 'Smi';
[torque] add union types This adds support for union types to Torque. There is a new type expression A | B to form the union of the type expressions A and B. This is only possible if A and B have a common supertype, to prevent nonsensical unions of types with different representations. Union types are normalized: A | B == B | A A | (B | C) == (A | B) | C A | A == A The subtyping rules are defined recursively: (A | B) <: C if A <: C and B <: C A <: (B | C) if A <: B or A <: C This allows to define Object as a union type: type Tagged generates 'TNode<Object>'; type Smi extends Tagged generates 'TNode<Smi>'; type HeapObject extends Tagged generates 'TNode<HeapObject>'; type Object = Smi | HeapObject; The type {Tagged} is introduced to have a common supertype of all tagged values, but we should not use it directly, because {Object} contains the additional information that there is nothing but {Smi} and {HeapObject} values. When mapping union types to CSA types, we select the most specific common supertype. For Number and Numeric, we already use union types on the CSA side. Since it is not possible to map to CSA union types in general, we special-case these two union types to map them to the CSA union types we already use. Bug: v8:7793 Change-Id: I7a4e466436f55d04012f29ef17acfdb957653908 Reviewed-on: https://chromium-review.googlesource.com/1076132 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53411}
2018-05-29 13:31:56 +00:00
type HeapObject extends Tagged generates 'TNode<HeapObject>';
type Object = Smi | HeapObject;
type int32 generates 'TNode<Int32T>' constexpr 'int32_t';
type uint32 generates 'TNode<Uint32T>' constexpr 'uint32_t';
type int64 generates 'TNode<Int64T>' constexpr 'int64_t';
type intptr generates 'TNode<IntPtrT>' constexpr 'intptr_t';
type uintptr generates 'TNode<UintPtrT>' constexpr 'uintptr_t';
type float32 generates 'TNode<Float32T>' constexpr 'float';
type float64 generates 'TNode<Float64T>' constexpr 'double';
type bool generates 'TNode<BoolT>' constexpr 'bool';
type bint generates 'TNode<BInt>' constexpr 'BInt';
type string constexpr 'const char*';
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
type int31 extends int32
generates 'TNode<Int32T>' constexpr 'int31_t';
type RawPtr generates 'TNode<RawPtrT>' constexpr 'void*';
type AbstractCode extends HeapObject generates 'TNode<AbstractCode>';
type Code extends AbstractCode generates 'TNode<Code>';
type BuiltinPtr extends Smi generates 'TNode<BuiltinPtr>';
type JSReceiver extends HeapObject generates 'TNode<JSReceiver>';
type Constructor extends JSReceiver generates 'TNode<JSReceiver>';
type Context extends HeapObject generates 'TNode<Context>';
type NativeContext extends Context generates 'TNode<Context>';
type String extends HeapObject generates 'TNode<String>';
type Oddball extends HeapObject generates 'TNode<Oddball>';
type HeapNumber extends HeapObject generates 'TNode<HeapNumber>';
type Number = Smi | HeapNumber;
type BigInt extends HeapObject generates 'TNode<BigInt>';
type Numeric = Number | BigInt;
[torque] add union types This adds support for union types to Torque. There is a new type expression A | B to form the union of the type expressions A and B. This is only possible if A and B have a common supertype, to prevent nonsensical unions of types with different representations. Union types are normalized: A | B == B | A A | (B | C) == (A | B) | C A | A == A The subtyping rules are defined recursively: (A | B) <: C if A <: C and B <: C A <: (B | C) if A <: B or A <: C This allows to define Object as a union type: type Tagged generates 'TNode<Object>'; type Smi extends Tagged generates 'TNode<Smi>'; type HeapObject extends Tagged generates 'TNode<HeapObject>'; type Object = Smi | HeapObject; The type {Tagged} is introduced to have a common supertype of all tagged values, but we should not use it directly, because {Object} contains the additional information that there is nothing but {Smi} and {HeapObject} values. When mapping union types to CSA types, we select the most specific common supertype. For Number and Numeric, we already use union types on the CSA side. Since it is not possible to map to CSA union types in general, we special-case these two union types to map them to the CSA union types we already use. Bug: v8:7793 Change-Id: I7a4e466436f55d04012f29ef17acfdb957653908 Reviewed-on: https://chromium-review.googlesource.com/1076132 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53411}
2018-05-29 13:31:56 +00:00
type JSProxy extends JSReceiver generates 'TNode<JSProxy>';
type JSObject extends JSReceiver generates 'TNode<JSObject>';
type JSArgumentsObjectWithLength extends JSObject
generates 'TNode<JSArgumentsObjectWithLength>';
type JSArray extends JSArgumentsObjectWithLength
generates 'TNode<JSArray>';
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
// A HeapObject with a JSArray map, and either fast packed elements, or fast
// holey elements when the global NoElementsProtector is not invalidated.
transient type FastJSArray extends JSArray
generates 'TNode<JSArray>';
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
// A FastJSArray when the global ArraySpeciesProtector is not invalidated.
transient type FastJSArrayForCopy extends FastJSArray
generates 'TNode<JSArray>';
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
// A FastJSArray when the global ArrayIteratorProtector is not invalidated.
transient type FastJSArrayWithNoCustomIteration extends FastJSArray
generates 'TNode<JSArray>';
type SharedFunctionInfo extends HeapObject
generates 'TNode<SharedFunctionInfo>';
[torque] add union types This adds support for union types to Torque. There is a new type expression A | B to form the union of the type expressions A and B. This is only possible if A and B have a common supertype, to prevent nonsensical unions of types with different representations. Union types are normalized: A | B == B | A A | (B | C) == (A | B) | C A | A == A The subtyping rules are defined recursively: (A | B) <: C if A <: C and B <: C A <: (B | C) if A <: B or A <: C This allows to define Object as a union type: type Tagged generates 'TNode<Object>'; type Smi extends Tagged generates 'TNode<Smi>'; type HeapObject extends Tagged generates 'TNode<HeapObject>'; type Object = Smi | HeapObject; The type {Tagged} is introduced to have a common supertype of all tagged values, but we should not use it directly, because {Object} contains the additional information that there is nothing but {Smi} and {HeapObject} values. When mapping union types to CSA types, we select the most specific common supertype. For Number and Numeric, we already use union types on the CSA side. Since it is not possible to map to CSA union types in general, we special-case these two union types to map them to the CSA union types we already use. Bug: v8:7793 Change-Id: I7a4e466436f55d04012f29ef17acfdb957653908 Reviewed-on: https://chromium-review.googlesource.com/1076132 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53411}
2018-05-29 13:31:56 +00:00
type JSFunction extends JSObject generates 'TNode<JSFunction>';
extern operator '.shared_function_info'
macro LoadJSFunctionSharedFunctionInfo(JSFunction): SharedFunctionInfo;
extern operator '.formal_parameter_count'
macro LoadSharedFunctionInfoFormalParameterCount(SharedFunctionInfo): int32;
[torque] add union types This adds support for union types to Torque. There is a new type expression A | B to form the union of the type expressions A and B. This is only possible if A and B have a common supertype, to prevent nonsensical unions of types with different representations. Union types are normalized: A | B == B | A A | (B | C) == (A | B) | C A | A == A The subtyping rules are defined recursively: (A | B) <: C if A <: C and B <: C A <: (B | C) if A <: B or A <: C This allows to define Object as a union type: type Tagged generates 'TNode<Object>'; type Smi extends Tagged generates 'TNode<Smi>'; type HeapObject extends Tagged generates 'TNode<HeapObject>'; type Object = Smi | HeapObject; The type {Tagged} is introduced to have a common supertype of all tagged values, but we should not use it directly, because {Object} contains the additional information that there is nothing but {Smi} and {HeapObject} values. When mapping union types to CSA types, we select the most specific common supertype. For Number and Numeric, we already use union types on the CSA side. Since it is not possible to map to CSA union types in general, we special-case these two union types to map them to the CSA union types we already use. Bug: v8:7793 Change-Id: I7a4e466436f55d04012f29ef17acfdb957653908 Reviewed-on: https://chromium-review.googlesource.com/1076132 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53411}
2018-05-29 13:31:56 +00:00
type JSBoundFunction extends JSObject generates 'TNode<JSBoundFunction>';
type Callable = JSFunction | JSBoundFunction | JSProxy;
type Map extends HeapObject generates 'TNode<Map>';
type FixedArrayBase extends HeapObject generates 'TNode<FixedArrayBase>';
type FixedArray extends FixedArrayBase generates 'TNode<FixedArray>';
type FixedDoubleArray extends FixedArrayBase
generates 'TNode<FixedDoubleArray>';
type FixedTypedArrayBase extends FixedArrayBase
generates 'TNode<FixedTypedArrayBase>';
type FixedTypedArray extends FixedTypedArrayBase
generates 'TNode<FixedTypedArray>';
type SloppyArgumentsElements extends FixedArray
generates 'TNode<FixedArray>';
type NumberDictionary extends HeapObject
generates 'TNode<NumberDictionary>';
// RawObjectCasts should *never* be used anywhere in Torque code except for
// in Torque-based UnsafeCast operators preceeded by an appropriate
// type assert()
intrinsic %RawObjectCast<A: type>(o: Object): A;
intrinsic %RawPointerCast<A: type>(p: RawPtr): A;
intrinsic %RawConstexprCast<To: type, From: type>(f: From): To;
type NativeContextSlot generates 'TNode<IntPtrT>' constexpr 'int32_t';
const ARRAY_JOIN_STACK_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_JOIN_STACK_INDEX';
const OBJECT_FUNCTION_INDEX: constexpr NativeContextSlot
generates 'Context::OBJECT_FUNCTION_INDEX';
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
const ITERATOR_RESULT_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::ITERATOR_RESULT_MAP_INDEX';
extern operator '[]' macro LoadContextElement(
NativeContext, NativeContextSlot): Object;
extern operator '[]=' macro StoreContextElement(
NativeContext, NativeContextSlot, Object): void;
extern operator '[]' macro LoadContextElement(Context, intptr): Object;
extern operator '[]' macro LoadContextElement(Context, Smi): Object;
type JSArrayBuffer extends JSObject generates 'TNode<JSArrayBuffer>';
type JSArrayBufferView extends JSObject
generates 'TNode<JSArrayBufferView>';
type JSTypedArray extends JSArrayBufferView
generates 'TNode<JSTypedArray>';
type JSDataView extends JSArrayBufferView generates 'TNode<JSDataView>';
type InstanceType generates 'TNode<Int32T>' constexpr 'InstanceType';
type ElementsKind generates 'TNode<Int32T>' constexpr 'ElementsKind';
type LanguageMode extends Tagged
generates 'TNode<Smi>' constexpr 'LanguageMode';
type ExtractFixedArrayFlags
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
generates 'TNode<Smi>'
constexpr 'CodeStubAssembler::ExtractFixedArrayFlags';
type ParameterMode
generates 'TNode<Int32T>' constexpr 'ParameterMode';
type RootIndex generates 'TNode<Int32T>' constexpr 'RootIndex';
type WriteBarrierMode
generates 'TNode<Int32T>' constexpr 'WriteBarrierMode';
type MessageTemplate constexpr 'MessageTemplate';
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
type ToIntegerTruncationMode
constexpr 'CodeStubAssembler::ToIntegerTruncationMode';
type AllocationFlags constexpr 'AllocationFlags';
const kSmiTagSize: constexpr int31 generates 'kSmiTagSize';
const NO_ELEMENTS: constexpr ElementsKind generates 'NO_ELEMENTS';
const PACKED_SMI_ELEMENTS:
constexpr ElementsKind generates 'PACKED_SMI_ELEMENTS';
const HOLEY_SMI_ELEMENTS:
constexpr ElementsKind generates 'HOLEY_SMI_ELEMENTS';
const PACKED_ELEMENTS:
constexpr ElementsKind generates 'PACKED_ELEMENTS';
const HOLEY_ELEMENTS: constexpr ElementsKind generates 'HOLEY_ELEMENTS';
const PACKED_DOUBLE_ELEMENTS:
constexpr ElementsKind generates 'PACKED_DOUBLE_ELEMENTS';
const HOLEY_DOUBLE_ELEMENTS:
constexpr ElementsKind generates 'HOLEY_DOUBLE_ELEMENTS';
const DICTIONARY_ELEMENTS:
constexpr ElementsKind generates 'DICTIONARY_ELEMENTS';
const UINT8_ELEMENTS: constexpr ElementsKind generates 'UINT8_ELEMENTS';
const INT8_ELEMENTS: constexpr ElementsKind generates 'INT8_ELEMENTS';
const UINT16_ELEMENTS:
constexpr ElementsKind generates 'UINT16_ELEMENTS';
const INT16_ELEMENTS: constexpr ElementsKind generates 'INT16_ELEMENTS';
const UINT32_ELEMENTS:
constexpr ElementsKind generates 'UINT32_ELEMENTS';
const INT32_ELEMENTS: constexpr ElementsKind generates 'INT32_ELEMENTS';
const FLOAT32_ELEMENTS:
constexpr ElementsKind generates 'FLOAT32_ELEMENTS';
const FLOAT64_ELEMENTS:
constexpr ElementsKind generates 'FLOAT64_ELEMENTS';
const UINT8_CLAMPED_ELEMENTS:
constexpr ElementsKind generates 'UINT8_CLAMPED_ELEMENTS';
const BIGUINT64_ELEMENTS:
constexpr ElementsKind generates 'BIGUINT64_ELEMENTS';
const BIGINT64_ELEMENTS:
constexpr ElementsKind generates 'BIGINT64_ELEMENTS';
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
const kNone:
constexpr AllocationFlags generates 'CodeStubAssembler::kNone';
const kDoubleAlignment:
constexpr AllocationFlags generates 'kDoubleAlignment';
const kPretenured: constexpr AllocationFlags generates 'kPretenured';
const kAllowLargeObjectAllocation:
constexpr AllocationFlags generates 'kAllowLargeObjectAllocation';
type FixedUint8Array extends FixedTypedArray;
type FixedInt8Array extends FixedTypedArray;
type FixedUint16Array extends FixedTypedArray;
type FixedInt16Array extends FixedTypedArray;
type FixedUint32Array extends FixedTypedArray;
type FixedInt32Array extends FixedTypedArray;
type FixedFloat32Array extends FixedTypedArray;
type FixedFloat64Array extends FixedTypedArray;
type FixedUint8ClampedArray extends FixedTypedArray;
type FixedBigUint64Array extends FixedTypedArray;
type FixedBigInt64Array extends FixedTypedArray;
const kFixedDoubleArrays: constexpr ExtractFixedArrayFlags
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
generates 'CodeStubAssembler::ExtractFixedArrayFlag::kFixedDoubleArrays';
const kAllFixedArrays: constexpr ExtractFixedArrayFlags
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
generates 'CodeStubAssembler::ExtractFixedArrayFlag::kAllFixedArrays';
const kFixedArrays: constexpr ExtractFixedArrayFlags
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
generates 'CodeStubAssembler::ExtractFixedArrayFlag::kFixedArrays';
const kFixedCOWArrayMapRootIndex:
constexpr RootIndex generates 'RootIndex::kFixedCOWArrayMap';
const kEmptyFixedArrayRootIndex:
constexpr RootIndex generates 'RootIndex::kEmptyFixedArray';
const kTheHoleValueRootIndex:
constexpr RootIndex generates 'RootIndex::kTheHoleValue';
const kInvalidArrayLength: constexpr MessageTemplate
generates 'MessageTemplate::kInvalidArrayLength';
const kCalledNonCallable: constexpr MessageTemplate
generates 'MessageTemplate::kCalledNonCallable';
const kCalledOnNullOrUndefined: constexpr MessageTemplate
generates 'MessageTemplate::kCalledOnNullOrUndefined';
const kIteratorValueNotAnObject: constexpr MessageTemplate
generates 'MessageTemplate::kIteratorValueNotAnObject';
const kNotIterable: constexpr MessageTemplate
generates 'MessageTemplate::kNotIterable';
const kMaxArrayIndex:
constexpr uint32 generates 'JSArray::kMaxArrayIndex';
const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger';
const kStringMaxLength: constexpr int31 generates 'String::kMaxLength';
const kFixedArrayMaxLength:
constexpr int31 generates 'FixedArray::kMaxLength';
const kMaxRegularHeapObjectSize: constexpr int31
generates 'kMaxRegularHeapObjectSize';
const kMaxNewSpaceFixedArrayElements: constexpr int31
generates 'FixedArray::kMaxRegularLength';
const kSloppyArgumentsArgumentsIndex: constexpr int31
generates 'SloppyArgumentsElements::kArgumentsIndex';
const kSloppyArgumentsContextIndex: constexpr int31
generates 'SloppyArgumentsElements::kContextIndex';
const kSloppyArgumentsParameterMapStart: constexpr int31
generates 'SloppyArgumentsElements::kParameterMapStart';
const kTruncateMinusZero: constexpr ToIntegerTruncationMode
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
generates 'CodeStubAssembler::ToIntegerTruncationMode::kTruncateMinusZero'
;
const kNotTypedArray: constexpr MessageTemplate
generates 'MessageTemplate::kNotTypedArray';
const kDetachedOperation: constexpr MessageTemplate
generates 'MessageTemplate::kDetachedOperation';
const kBadSortComparisonFunction: constexpr MessageTemplate
generates 'MessageTemplate::kBadSortComparisonFunction';
const kIncompatibleMethodReceiver: constexpr MessageTemplate
generates 'MessageTemplate::kIncompatibleMethodReceiver';
const kInvalidDataViewAccessorOffset: constexpr MessageTemplate
generates 'MessageTemplate::kInvalidDataViewAccessorOffset';
const kStrictReadOnlyProperty: constexpr MessageTemplate
generates 'MessageTemplate::kStrictReadOnlyProperty';
type Hole extends Oddball generates 'TNode<Oddball>';
type Null extends Oddball generates 'TNode<Oddball>';
type Undefined extends Oddball generates 'TNode<Oddball>';
type True extends Oddball generates 'TNode<Oddball>';
type False extends Oddball generates 'TNode<Oddball>';
type Boolean = True | False;
type NumberOrUndefined = Number | Undefined;
extern macro TheHoleConstant(): Hole;
extern macro NullConstant(): Null;
extern macro UndefinedConstant(): Undefined;
extern macro TrueConstant(): True;
extern macro FalseConstant(): False;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern macro Int32TrueConstant(): bool;
extern macro Int32FalseConstant(): bool;
extern macro EmptyStringConstant(): String;
extern macro LengthStringConstant(): String;
const Hole: Hole = TheHoleConstant();
const Null: Null = NullConstant();
const Undefined: Undefined = UndefinedConstant();
const True: True = TrueConstant();
const False: False = FalseConstant();
const kEmptyString: String = EmptyStringConstant();
const kLengthString: String = LengthStringConstant();
const true: constexpr bool generates 'true';
const false: constexpr bool generates 'false';
const kStrict: constexpr LanguageMode generates 'LanguageMode::kStrict';
const kSloppy: constexpr LanguageMode generates 'LanguageMode::kSloppy';
[torque] enable multiple inheritance from Torque-generated assemblers This enables more seamless interop between Torque and CSA: Since CodeStubAssembler can now inherit from the Torque base namespace, macros defined in the base namespace can be used in CodeStubAssembler macros, even without qualification. At the same time, macros in the base namespace can refer to CodeStubAssembler macros. The only new limitation is that types defined in code-stub-assembler.h cannot be referenced in the signature of macros defined in the base namespace, since this would produce a cyclic header dependency. A work-around for this woud be to put such types (like int31 in this CL) into a separate header included by both. I (mis-)used code-assembler.h for that. Another side-effec is that types and enums defined in CodeStubAssembler have to be accessed in a qualified way from Torque. Other assemblers can now inherit from their Torque equivalent, so porting macros into the corresponding Torque namespace doesn't require any change to the existing use-sites. To avoid C++ ambiguities, the Torque-generated assemblers must not define anything also defined in Code(Stub)Assembler. This includes the type aliases for TNode, PLabel, ... My workaround is to qualify everything in the generated C++. As a drive-by fix, I had to change the formatter to avoid a situation where it doesn't compute a fixed point: putting a keyword at the beginning of a line removes the '\s' in front of it, so I replaced that with '\b'. Bug: v8:7793 Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041 Reviewed-on: https://chromium-review.googlesource.com/c/1341955 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
const SMI_PARAMETERS: constexpr ParameterMode
generates 'CodeStubAssembler::SMI_PARAMETERS';
const INTPTR_PARAMETERS: constexpr ParameterMode
generates 'CodeStubAssembler::INTPTR_PARAMETERS';
const SKIP_WRITE_BARRIER:
constexpr WriteBarrierMode generates 'SKIP_WRITE_BARRIER';
extern macro Is64(): constexpr bool;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern macro SelectBooleanConstant(bool): Boolean;
extern macro Print(constexpr string);
extern macro Print(constexpr string, Object);
extern macro Comment(constexpr string);
extern macro Print(Object);
extern macro DebugBreak();
extern macro ToInteger_Inline(Context, Object): Number;
extern macro ToInteger_Inline(
Context, Object, constexpr ToIntegerTruncationMode): Number;
extern macro ToLength_Inline(Context, Object): Number;
extern macro ToNumber_Inline(Context, Object): Number;
extern macro ToString_Inline(Context, Object): String;
extern transitioning macro GetProperty(implicit context: Context)(
Object, Object): Object;
extern transitioning builtin SetProperty(implicit context: Context)(
Object, Object, Object);
extern transitioning builtin SetPropertyInLiteral(implicit context: Context)(
Object, Object, Object);
extern transitioning builtin DeleteProperty(implicit context: Context)(
Object, Object, LanguageMode);
extern transitioning builtin HasProperty(implicit context: Context)(
JSReceiver, Object): Boolean;
extern transitioning macro HasProperty_Inline(implicit context: Context)(
JSReceiver, Object): Boolean;
extern macro ThrowRangeError(Context, constexpr MessageTemplate): never;
extern macro ThrowTypeError(Context, constexpr MessageTemplate): never;
extern macro ThrowTypeError(Context, constexpr MessageTemplate, Object): never;
extern macro ThrowTypeError(
Context, constexpr MessageTemplate, Object, Object, Object): never;
extern macro ArraySpeciesCreate(Context, Object, Number): JSReceiver;
extern macro ArrayCreate(implicit context: Context)(Number): JSArray;
extern macro BuildAppendJSArray(
constexpr ElementsKind, FastJSArray, Object): void labels Bailout;
extern macro EnsureArrayPushable(Map): ElementsKind
labels Bailout;
extern macro EnsureArrayLengthWritable(Map) labels Bailout;
// TODO: Reduce duplication once varargs are supported in macros.
extern macro Construct(implicit context: Context)(
Constructor, Object): JSReceiver;
extern macro Construct(implicit context: Context)(
Constructor, Object, Object): JSReceiver;
extern macro Construct(implicit context: Context)(
Constructor, Object, Object, Object): JSReceiver;
Reland "[array] Use random middle element to determine pivot during sorting" This is a reland of 91bab5588c60497e200fa89a846e136b695db510 This CL contains two major changes w.r.t to the original CL: The random state is removed from the Smi root list and we pre-seed the RNG on each sort with the length of the array. To cut down on the length of the arguments list and to keep track of the random state across recursive calls, we move most of the sort arguments into a FixedArray and reload from the array for each recursion. Original change's description: > [array] Use random middle element to determine pivot during sorting > > This CL adds a "random state" to the Smi Root list and implements a > basic Linear congruential pseudo random number generator in Torque. > > The RNG is used to determine the pivot element for sorting. This will > prevent the worst cases for certain data layouts. > > Drive-by-fix: Make sorting of ranges and execution pauses for profviz > deterministic by adding a secondary sorting criteria. > > Bug: v8:7382 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Ieb871e98e74bdb803f821b0cd35d2f67ee0f2868 > Reviewed-on: https://chromium-review.googlesource.com/1082193 > Reviewed-by: Hannes Payer <hpayer@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > Commit-Queue: Simon Zünd <szuend@google.com> > Cr-Commit-Position: refs/heads/master@{#53524} Bug: v8:7382 Change-Id: Ia7bef7ed1c0e904ffe43bc428e702f64f9c6a60b Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Reviewed-on: https://chromium-review.googlesource.com/1087888 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Simon Zünd <szuend@google.com> Cr-Commit-Position: refs/heads/master@{#53583}
2018-06-07 11:48:26 +00:00
extern builtin ToObject(Context, Object): JSReceiver;
extern macro ToObject_Inline(Context, Object): JSReceiver;
extern macro IsNullOrUndefined(Object): bool;
extern macro IsTheHole(Object): bool;
extern macro IsString(HeapObject): bool;
extern builtin ToString(Context, Object): String;
extern transitioning runtime NormalizeElements(Context, JSObject);
extern transitioning runtime TransitionElementsKindWithKind(
Context, JSObject, Smi);
extern transitioning runtime CreateDataProperty(implicit context: Context)(
JSReceiver, Object, Object);
extern macro LoadBufferObject(RawPtr, constexpr int32): Object;
extern macro LoadBufferPointer(RawPtr, constexpr int32): RawPtr;
extern macro LoadBufferSmi(RawPtr, constexpr int32): Smi;
extern macro LoadRoot(constexpr RootIndex): Object;
extern macro StoreRoot(constexpr RootIndex, Object): Object;
extern macro LoadAndUntagToWord32Root(constexpr RootIndex): int32;
Reland "[array] Use random middle element to determine pivot during sorting" This is a reland of 91bab5588c60497e200fa89a846e136b695db510 This CL contains two major changes w.r.t to the original CL: The random state is removed from the Smi root list and we pre-seed the RNG on each sort with the length of the array. To cut down on the length of the arguments list and to keep track of the random state across recursive calls, we move most of the sort arguments into a FixedArray and reload from the array for each recursion. Original change's description: > [array] Use random middle element to determine pivot during sorting > > This CL adds a "random state" to the Smi Root list and implements a > basic Linear congruential pseudo random number generator in Torque. > > The RNG is used to determine the pivot element for sorting. This will > prevent the worst cases for certain data layouts. > > Drive-by-fix: Make sorting of ranges and execution pauses for profviz > deterministic by adding a secondary sorting criteria. > > Bug: v8:7382 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Ieb871e98e74bdb803f821b0cd35d2f67ee0f2868 > Reviewed-on: https://chromium-review.googlesource.com/1082193 > Reviewed-by: Hannes Payer <hpayer@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > Commit-Queue: Simon Zünd <szuend@google.com> > Cr-Commit-Position: refs/heads/master@{#53524} Bug: v8:7382 Change-Id: Ia7bef7ed1c0e904ffe43bc428e702f64f9c6a60b Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Reviewed-on: https://chromium-review.googlesource.com/1087888 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Simon Zünd <szuend@google.com> Cr-Commit-Position: refs/heads/master@{#53583}
2018-06-07 11:48:26 +00:00
extern runtime StringEqual(Context, String, String): Oddball;
extern builtin StringLessThan(Context, String, String): Boolean;
extern macro StrictEqual(Object, Object): Boolean;
extern macro SmiLexicographicCompare(Smi, Smi): Smi;
extern runtime ReThrow(Context, Object): never;
extern runtime ThrowInvalidStringLength(Context): never;
extern operator '==' macro WordEqual(RawPtr, RawPtr): bool;
extern operator '!=' macro WordNotEqual(RawPtr, RawPtr): bool;
extern operator '<' macro Int32LessThan(int32, int32): bool;
extern operator '<' macro Uint32LessThan(uint32, uint32): bool;
extern operator '>' macro Int32GreaterThan(int32, int32): bool;
extern operator '>' macro Uint32GreaterThan(uint32, uint32): bool;
extern operator '<=' macro Int32LessThanOrEqual(int32, int32): bool;
extern operator '<=' macro Uint32LessThanOrEqual(uint32, uint32): bool;
extern operator '>=' macro Int32GreaterThanOrEqual(int32, int32): bool;
extern operator '>=' macro Uint32GreaterThanOrEqual(uint32, uint32): bool;
extern operator '==' macro SmiEqual(Smi, Smi): bool;
extern operator '!=' macro SmiNotEqual(Smi, Smi): bool;
extern operator '<' macro SmiLessThan(Smi, Smi): bool;
extern operator '<=' macro SmiLessThanOrEqual(Smi, Smi): bool;
extern operator '>' macro SmiGreaterThan(Smi, Smi): bool;
extern operator '>=' macro SmiGreaterThanOrEqual(Smi, Smi): bool;
extern operator '==' macro ElementsKindEqual(
constexpr ElementsKind, constexpr ElementsKind): constexpr bool;
extern operator '==' macro ElementsKindEqual(ElementsKind, ElementsKind): bool;
operator '!=' macro ElementsKindNotEqual(
k1: ElementsKind, k2: ElementsKind): bool {
return !ElementsKindEqual(k1, k2);
}
extern macro IsElementsKindLessThanOrEqual(
ElementsKind, constexpr ElementsKind): bool;
extern macro IsElementsKindGreaterThan(
ElementsKind, constexpr ElementsKind): bool;
extern macro IsFastElementsKind(constexpr ElementsKind): constexpr bool;
extern macro IsDoubleElementsKind(constexpr ElementsKind): constexpr bool;
extern macro IsFastAliasedArgumentsMap(implicit context: Context)(Map): bool;
extern macro IsSlowAliasedArgumentsMap(implicit context: Context)(Map): bool;
extern macro IsSloppyArgumentsMap(implicit context: Context)(Map): bool;
extern macro IsStrictArgumentsMap(implicit context: Context)(Map): bool;
extern macro SmiAbove(Smi, Smi): bool;
extern operator '==' macro WordEqual(intptr, intptr): bool;
extern operator '==' macro WordEqual(uintptr, uintptr): bool;
extern operator '!=' macro WordNotEqual(intptr, intptr): bool;
extern operator '!=' macro WordNotEqual(uintptr, uintptr): bool;
extern operator '<' macro IntPtrLessThan(intptr, intptr): bool;
extern operator '<' macro UintPtrLessThan(uintptr, uintptr): bool;
extern operator '>' macro IntPtrGreaterThan(intptr, intptr): bool;
extern operator '>' macro UintPtrGreaterThan(uintptr, uintptr): bool;
extern operator '<=' macro IntPtrLessThanOrEqual(intptr, intptr): bool;
extern operator '<=' macro UintPtrLessThanOrEqual(uintptr, uintptr): bool;
extern operator '>=' macro IntPtrGreaterThanOrEqual(intptr, intptr): bool;
extern operator '>=' macro UintPtrGreaterThanOrEqual(uintptr, uintptr): bool;
extern operator '==' macro Float64Equal(float64, float64): bool;
extern operator '!=' macro Float64NotEqual(float64, float64): bool;
extern operator '>' macro Float64GreaterThan(float64, float64): bool;
extern operator '==' macro BranchIfNumberEqual(Number, Number): never
labels Taken, NotTaken;
extern operator '!=' macro BranchIfNumberNotEqual(Number, Number): never
labels Taken, NotTaken;
extern operator '<' macro BranchIfNumberLessThan(Number, Number): never
labels Taken, NotTaken;
extern operator '<=' macro BranchIfNumberLessThanOrEqual(Number, Number): never
labels Taken, NotTaken;
extern operator '>' macro BranchIfNumberGreaterThan(Number, Number): never
labels Taken, NotTaken;
extern operator '>=' macro BranchIfNumberGreaterThanOrEqual(
Number, Number): never
labels Taken, NotTaken;
extern operator '==' macro WordEqual(Object, Object): bool;
extern operator '!=' macro WordNotEqual(Object, Object): bool;
extern operator '+' macro SmiAdd(Smi, Smi): Smi;
extern operator '-' macro SmiSub(Smi, Smi): Smi;
extern operator '&' macro SmiAnd(Smi, Smi): Smi;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern operator '|' macro SmiOr(Smi, Smi): Smi;
extern operator '<<' macro SmiShl(Smi, constexpr int31): Smi;
extern operator '>>' macro SmiSar(Smi, constexpr int31): Smi;
extern operator '+' macro IntPtrAdd(intptr, intptr): intptr;
extern operator '-' macro IntPtrSub(intptr, intptr): intptr;
extern operator '*' macro IntPtrMul(intptr, intptr): intptr;
extern operator '/' macro IntPtrDiv(intptr, intptr): intptr;
extern operator '<<' macro WordShl(intptr, intptr): intptr;
extern operator '>>' macro WordSar(intptr, intptr): intptr;
extern operator '&' macro WordAnd(intptr, intptr): intptr;
extern operator '|' macro WordOr(intptr, intptr): intptr;
extern operator '+' macro UintPtrAdd(uintptr, uintptr): uintptr;
extern operator '-' macro UintPtrSub(uintptr, uintptr): uintptr;
extern operator '>>>' macro WordShr(uintptr, uintptr): uintptr;
extern operator '&' macro WordAnd(uintptr, uintptr): uintptr;
extern operator '|' macro WordOr(uintptr, uintptr): uintptr;
extern operator '+' macro Int32Add(int32, int32): int32;
extern operator '+' macro ConstexprUint32Add(
constexpr uint32, constexpr int32): constexpr uint32;
extern operator '-' macro Int32Sub(int32, int32): int32;
extern operator '*' macro Int32Mul(int32, int32): int32;
extern operator '%' macro Int32Mod(int32, int32): int32;
extern operator '&' macro Word32And(int32, int32): int32;
extern operator '&' macro Word32And(uint32, uint32): uint32;
extern operator '==' macro
ConstexprInt31Equal(constexpr int31, constexpr int31): constexpr bool;
extern operator '==' macro Word32Equal(int32, int32): bool;
extern operator '==' macro Word32Equal(uint32, uint32): bool;
extern operator '!=' macro Word32NotEqual(int32, int32): bool;
extern operator '!=' macro Word32NotEqual(uint32, uint32): bool;
extern operator '>>>' macro Word32Shr(uint32, uint32): uint32;
extern operator '<<' macro Word32Shl(int32, int32): int32;
extern operator '<<' macro Word32Shl(uint32, uint32): uint32;
extern operator '|' macro Word32Or(int32, int32): int32;
extern operator '|' macro Word32Or(uint32, uint32): uint32;
extern operator '&' macro Word32And(bool, bool): bool;
extern operator '|' macro Word32Or(bool, bool): bool;
extern operator '+' macro Float64Add(float64, float64): float64;
extern operator '+' macro NumberAdd(Number, Number): Number;
extern operator '-' macro NumberSub(Number, Number): Number;
extern macro NumberMin(Number, Number): Number;
extern macro NumberMax(Number, Number): Number;
macro Min(x: Number, y: Number): Number {
return NumberMin(x, y);
}
macro Max(x: Number, y: Number): Number {
return NumberMax(x, y);
}
extern operator '<<' macro ConstexprUintPtrShl(
constexpr uintptr, constexpr int31): constexpr uintptr;
extern operator '>>>' macro ConstexprUintPtrShr(
constexpr uintptr, constexpr int31): constexpr uintptr;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern macro SmiMax(Smi, Smi): Smi;
extern macro SmiMin(Smi, Smi): Smi;
extern operator '!' macro ConstexprBoolNot(constexpr bool): constexpr bool;
extern operator '!' macro Word32BinaryNot(bool): bool;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern operator '!' macro IsFalse(Boolean): bool;
extern operator '.map' macro LoadMap(HeapObject): Map;
extern transitioning operator '.map=' macro StoreMap(HeapObject, Map);
extern operator '.instanceType' macro LoadInstanceType(HeapObject):
InstanceType;
extern operator '.length' macro LoadStringLengthAsWord(String): intptr;
extern operator '.length' macro GetArgumentsLength(constexpr Arguments): intptr;
extern operator '[]' macro GetArgumentValue(
constexpr Arguments, intptr): Object;
extern macro TaggedIsSmi(Object): bool;
extern macro TaggedIsNotSmi(Object): bool;
Reland "[array] Use random middle element to determine pivot during sorting" This is a reland of 91bab5588c60497e200fa89a846e136b695db510 This CL contains two major changes w.r.t to the original CL: The random state is removed from the Smi root list and we pre-seed the RNG on each sort with the length of the array. To cut down on the length of the arguments list and to keep track of the random state across recursive calls, we move most of the sort arguments into a FixedArray and reload from the array for each recursion. Original change's description: > [array] Use random middle element to determine pivot during sorting > > This CL adds a "random state" to the Smi Root list and implements a > basic Linear congruential pseudo random number generator in Torque. > > The RNG is used to determine the pivot element for sorting. This will > prevent the worst cases for certain data layouts. > > Drive-by-fix: Make sorting of ranges and execution pauses for profviz > deterministic by adding a secondary sorting criteria. > > Bug: v8:7382 > Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng > Change-Id: Ieb871e98e74bdb803f821b0cd35d2f67ee0f2868 > Reviewed-on: https://chromium-review.googlesource.com/1082193 > Reviewed-by: Hannes Payer <hpayer@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > Commit-Queue: Simon Zünd <szuend@google.com> > Cr-Commit-Position: refs/heads/master@{#53524} Bug: v8:7382 Change-Id: Ia7bef7ed1c0e904ffe43bc428e702f64f9c6a60b Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Reviewed-on: https://chromium-review.googlesource.com/1087888 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Simon Zünd <szuend@google.com> Cr-Commit-Position: refs/heads/master@{#53583}
2018-06-07 11:48:26 +00:00
extern macro TaggedIsPositiveSmi(Object): bool;
extern macro IsValidPositiveSmi(intptr): bool;
extern macro HeapObjectToJSDataView(HeapObject): JSDataView
labels CastError;
extern macro HeapObjectToJSTypedArray(HeapObject): JSTypedArray
labels CastError;
extern macro TaggedToHeapObject(Object): HeapObject
labels CastError;
extern macro TaggedToSmi(Object): Smi
labels CastError;
extern macro HeapObjectToJSArray(HeapObject): JSArray
labels CastError;
extern macro HeapObjectToCallable(HeapObject): Callable
labels CastError;
extern macro HeapObjectToFixedArray(HeapObject): FixedArray
labels CastError;
extern macro HeapObjectToFixedDoubleArray(HeapObject): FixedDoubleArray
labels CastError;
extern macro HeapObjectToString(HeapObject): String
labels CastError;
extern macro HeapObjectToConstructor(HeapObject): Constructor
labels CastError;
extern macro HeapObjectToHeapNumber(HeapObject): HeapNumber
labels CastError;
extern macro HeapObjectToSloppyArgumentsElements(HeapObject):
SloppyArgumentsElements
labels CastError;
extern macro TaggedToNumber(Object): Number
labels CastError;
macro CastHeapObject<A: type>(o: HeapObject): A
labels CastError;
CastHeapObject<HeapObject>(o: HeapObject): HeapObject
labels CastError {
return o;
}
CastHeapObject<FixedArray>(o: HeapObject): FixedArray
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return HeapObjectToFixedArray(o) otherwise CastError;
}
CastHeapObject<FixedDoubleArray>(o: HeapObject): FixedDoubleArray
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return HeapObjectToFixedDoubleArray(o) otherwise CastError;
}
CastHeapObject<SloppyArgumentsElements>(o: HeapObject): SloppyArgumentsElements
labels CastError {
return HeapObjectToSloppyArgumentsElements(o) otherwise CastError;
}
CastHeapObject<JSDataView>(o: HeapObject): JSDataView
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return HeapObjectToJSDataView(o) otherwise CastError;
}
CastHeapObject<JSTypedArray>(o: HeapObject): JSTypedArray
labels CastError {
if (IsJSTypedArray(o)) return %RawObjectCast<JSTypedArray>(o);
goto CastError;
}
CastHeapObject<Callable>(o: HeapObject): Callable
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return HeapObjectToCallable(o) otherwise CastError;
}
CastHeapObject<JSArray>(o: HeapObject): JSArray
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return HeapObjectToJSArray(o) otherwise CastError;
}
CastHeapObject<Context>(o: HeapObject): Context
labels CastError {
if (IsContext(o)) return %RawObjectCast<Context>(o);
goto CastError;
}
CastHeapObject<JSObject>(o: HeapObject): JSObject
labels CastError {
if (IsJSObject(o)) return %RawObjectCast<JSObject>(o);
goto CastError;
}
CastHeapObject<NumberDictionary>(o: HeapObject): NumberDictionary
labels CastError {
if (IsNumberDictionary(o)) return %RawObjectCast<NumberDictionary>(o);
goto CastError;
}
CastHeapObject<FixedTypedArrayBase>(o: HeapObject): FixedTypedArrayBase
labels CastError {
if (IsFixedTypedArray(o)) return %RawObjectCast<FixedTypedArrayBase>(o);
goto CastError;
}
CastHeapObject<String>(o: HeapObject): String
labels CastError {
return HeapObjectToString(o) otherwise CastError;
}
CastHeapObject<Constructor>(o: HeapObject): Constructor
labels CastError {
return HeapObjectToConstructor(o) otherwise CastError;
}
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
CastHeapObject<HeapNumber>(o: HeapObject): HeapNumber
labels CastError {
if (IsHeapNumber(o)) return %RawObjectCast<HeapNumber>(o);
goto CastError;
}
CastHeapObject<Map>(implicit context: Context)(o: HeapObject): Map
labels CastError {
if (IsMap(o)) return %RawObjectCast<Map>(o);
goto CastError;
}
CastHeapObject<JSArgumentsObjectWithLength>(implicit context: Context)(
o: HeapObject): JSArgumentsObjectWithLength
labels CastError {
const map: Map = o.map;
try {
if (IsFastAliasedArgumentsMap(map)) goto True;
if (IsSloppyArgumentsMap(map)) goto True;
if (IsStrictArgumentsMap(map)) goto True;
if (IsSlowAliasedArgumentsMap(map)) goto True;
goto CastError;
}
label True {
return %RawObjectCast<JSArgumentsObjectWithLength>(o);
}
}
CastHeapObject<FastJSArray>(implicit context: Context)(o: HeapObject):
FastJSArray
labels CastError {
const map: Map = o.map;
if (!IsJSArrayMap(map)) goto CastError;
// Bailout if receiver has slow elements.
const elementsKind: ElementsKind = LoadMapElementsKind(map);
if (!IsFastElementsKind(elementsKind)) goto CastError;
// Verify that our prototype is the initial array prototype.
if (!IsPrototypeInitialArrayPrototype(map)) goto CastError;
if (IsNoElementsProtectorCellInvalid()) goto CastError;
return %RawObjectCast<FastJSArray>(o);
}
struct FastJSArrayWitness {
array: HeapObject;
map: Map;
}
macro MakeWitness(array: FastJSArray): FastJSArrayWitness {
return FastJSArrayWitness{array, array.map};
}
macro Testify(witness: FastJSArrayWitness): FastJSArray labels CastError {
if (witness.array.map != witness.map) goto CastError;
// We don't need to check elements kind or whether the prototype
// has changed away from the default JSArray prototype, because
// if the map remains the same then those properties hold.
//
// However, we have to make sure there are no elements in the
// prototype chain.
if (IsNoElementsProtectorCellInvalid()) goto CastError;
return %RawObjectCast<FastJSArray>(witness.array);
}
CastHeapObject<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject):
FastJSArrayForCopy
labels CastError {
if (IsArraySpeciesProtectorCellInvalid()) goto CastError;
const a: FastJSArray = Cast<FastJSArray>(o) otherwise CastError;
return %RawObjectCast<FastJSArrayForCopy>(o);
}
CastHeapObject<FastJSArrayWithNoCustomIteration>(implicit context: Context)(
o: HeapObject): FastJSArrayWithNoCustomIteration
labels CastError {
if (IsArrayIteratorProtectorCellInvalid()) goto CastError;
const a: FastJSArray = Cast<FastJSArray>(o) otherwise CastError;
return %RawObjectCast<FastJSArrayWithNoCustomIteration>(o);
}
CastHeapObject<JSReceiver>(implicit context: Context)(o: HeapObject): JSReceiver
labels CastError {
if (IsJSReceiver(o)) return %RawObjectCast<JSReceiver>(o);
goto CastError;
}
CastHeapObject<JSFunction>(implicit context: Context)(o: HeapObject): JSFunction
labels CastError {
if (IsJSFunction(o)) return %RawObjectCast<JSFunction>(o);
goto CastError;
}
macro Cast<A: type>(implicit context: Context)(o: HeapObject): A
labels CastError {
return CastHeapObject<A>(o) otherwise CastError;
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
}
// CastHeapObject allows this default-implementation to be non-recursive.
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
// Otherwise the generated CSA code might run into infinite recursion.
macro Cast<A: type>(implicit context: Context)(o: Object): A
labels CastError {
return CastHeapObject<A>(TaggedToHeapObject(o) otherwise CastError)
otherwise CastError;
}
Cast<Smi>(o: Object): Smi
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return TaggedToSmi(o) otherwise CastError;
}
Cast<Number>(o: Object): Number
labels CastError {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return TaggedToNumber(o) otherwise CastError;
}
extern macro AllocateHeapNumberWithValue(float64): HeapNumber;
extern macro ChangeInt32ToTagged(int32): Number;
extern macro ChangeUint32ToTagged(uint32): Number;
extern macro ChangeUintPtrToFloat64(uintptr): float64;
extern macro ChangeUintPtrToTagged(uintptr): Number;
extern macro Unsigned(int32): uint32;
extern macro Unsigned(intptr): uintptr;
extern macro Unsigned(RawPtr): uintptr;
extern macro Signed(uint32): int32;
extern macro Signed(uintptr): intptr;
extern macro Signed(RawPtr): intptr;
extern macro TruncateIntPtrToInt32(intptr): int32;
extern macro SmiTag(intptr): Smi;
extern macro SmiFromInt32(int32): Smi;
extern macro SmiUntag(Smi): intptr;
extern macro SmiToInt32(Smi): int32;
extern macro RoundIntPtrToFloat64(intptr): float64;
extern macro LoadHeapNumberValue(HeapNumber): float64;
extern macro ChangeFloat32ToFloat64(float32): float64;
extern macro ChangeNumberToFloat64(Number): float64;
extern macro ChangeFloat64ToUintPtr(float64): uintptr;
extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends.
extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend.
extern macro LoadNativeContext(Context): NativeContext;
extern macro LoadJSArrayElementsMap(constexpr ElementsKind, Context): Map;
extern macro LoadJSArrayElementsMap(ElementsKind, Context): Map;
extern macro ChangeNonnegativeNumberToUintPtr(Number): uintptr;
extern macro NumberConstant(constexpr float64): Number;
extern macro NumberConstant(constexpr int32): Number;
extern macro NumberConstant(constexpr uint32): Number;
extern macro IntPtrConstant(constexpr int31): intptr;
extern macro IntPtrConstant(constexpr int32): intptr;
extern macro Int32Constant(constexpr int31): int31;
extern macro Int32Constant(constexpr int32): int32;
extern macro Float64Constant(constexpr int31): float64;
extern macro SmiConstant(constexpr int31): Smi;
extern macro SmiConstant(constexpr Smi): Smi;
extern macro BoolConstant(constexpr bool): bool;
extern macro StringConstant(constexpr string): String;
extern macro LanguageModeConstant(constexpr LanguageMode): LanguageMode;
extern macro Int32Constant(constexpr ElementsKind): ElementsKind;
extern macro IntPtrConstant(constexpr NativeContextSlot): NativeContextSlot;
extern macro IntPtrConstant(constexpr intptr): intptr;
extern macro BitcastWordToTaggedSigned(intptr): Smi;
extern macro BitcastWordToTaggedSigned(uintptr): Smi;
extern macro BitcastWordToTagged(intptr): Object;
extern macro BitcastWordToTagged(uintptr): Object;
extern macro BitcastTaggedToWord(Tagged): intptr;
intrinsic %FromConstexpr<To: type, From: type>(b: From): To;
macro FromConstexpr<To: type, From: type>(o: From): To;
FromConstexpr<int31, constexpr int31>(i: constexpr int31): int31 {
return %FromConstexpr<int31>(i);
}
FromConstexpr<int32, constexpr int31>(i: constexpr int31): int32 {
return %FromConstexpr<int32>(i);
}
FromConstexpr<int32, constexpr int32>(i: constexpr int32): int32 {
return %FromConstexpr<int32>(i);
}
FromConstexpr<intptr, constexpr int31>(i: constexpr int31): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<intptr, constexpr int32>(i: constexpr int32): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<intptr, constexpr intptr>(i: constexpr intptr): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<uintptr, constexpr uintptr>(i: constexpr uintptr): uintptr {
return %FromConstexpr<uintptr>(i);
}
FromConstexpr<Smi, constexpr int31>(i: constexpr int31): Smi {
return %FromConstexpr<Smi>(i);
}
FromConstexpr<String, constexpr string>(s: constexpr string): String {
return %FromConstexpr<String>(s);
}
FromConstexpr<Number, constexpr uint32>(i: constexpr uint32): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr int32>(i: constexpr int32): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr float64>(f: constexpr float64): Number {
return %FromConstexpr<Number>(f);
}
FromConstexpr<Number, constexpr int31>(i: constexpr int31): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr Smi>(s: constexpr Smi): Number {
return SmiConstant(s);
}
FromConstexpr<Smi, constexpr Smi>(s: constexpr Smi): Smi {
return SmiConstant(s);
}
FromConstexpr<uint32, constexpr int31>(i: constexpr int31): uint32 {
return Unsigned(Int32Constant(i));
}
FromConstexpr<uintptr, constexpr int31>(i: constexpr int31): uintptr {
return ChangeUint32ToWord(i);
}
FromConstexpr<float64, constexpr int31>(i: constexpr int31): float64 {
return Float64Constant(i);
}
FromConstexpr<bool, constexpr bool>(b: constexpr bool): bool {
return BoolConstant(b);
}
FromConstexpr<LanguageMode, constexpr LanguageMode>(m: constexpr LanguageMode):
LanguageMode {
return %RawObjectCast<LanguageMode>(%FromConstexpr<Smi>(m));
}
FromConstexpr<ElementsKind, constexpr ElementsKind>(e: constexpr ElementsKind):
ElementsKind {
return Int32Constant(e);
}
FromConstexpr<Object, constexpr string>(s: constexpr string): Object {
return StringConstant(s);
}
FromConstexpr<NativeContextSlot, constexpr NativeContextSlot>(
c: constexpr NativeContextSlot): NativeContextSlot {
return IntPtrConstant(c);
}
macro Convert<To: type, From: type>(i: From): To {
return i;
}
extern macro ConvertElementsKindToInt(ElementsKind): int32;
Convert<int32, ElementsKind>(elementsKind: ElementsKind): int32 {
return ConvertElementsKindToInt(elementsKind);
}
Convert<Number, int32>(i: int32): Number {
return ChangeInt32ToTagged(i);
}
Convert<intptr, int32>(i: int32): intptr {
return ChangeInt32ToIntPtr(i);
}
Convert<Smi, int32>(i: int32): Smi {
return SmiFromInt32(i);
}
Convert<Number, uint32>(ui: uint32): Number {
return ChangeUint32ToTagged(ui);
}
Convert<Smi, uint32>(ui: uint32): Smi {
return SmiFromInt32(Signed(ui));
}
Convert<uintptr, uint32>(ui: uint32): uintptr {
return ChangeUint32ToWord(ui);
}
Convert<int32, intptr>(i: intptr): int32 {
return TruncateIntPtrToInt32(i);
}
Convert<Smi, intptr>(i: intptr): Smi {
return SmiTag(i);
}
Convert<uint32, uintptr>(ui: uintptr): uint32 {
return Unsigned(TruncateIntPtrToInt32(Signed(ui)));
}
Convert<intptr, Smi>(s: Smi): intptr {
return SmiUntag(s);
}
Convert<int32, Smi>(s: Smi): int32 {
return SmiToInt32(s);
}
Convert<float64, HeapNumber>(h: HeapNumber): float64 {
return LoadHeapNumberValue(h);
}
Convert<float64, Number>(n: Number): float64 {
return ChangeNumberToFloat64(n);
}
Convert<uintptr, Number>(n: Number): uintptr {
return ChangeNonnegativeNumberToUintPtr(n);
}
Convert<float64, float32>(f: float32): float64 {
return ChangeFloat32ToFloat64(f);
}
Convert<Number, float64>(d: float64): Number {
return AllocateHeapNumberWithValue(d);
}
Convert<float64, uintptr>(ui: uintptr): float64 {
return ChangeUintPtrToFloat64(ui);
}
Convert<Number, uintptr>(ui: uintptr): Number {
return ChangeUintPtrToTagged(ui);
}
Convert<uintptr, float64>(d: float64): uintptr {
return ChangeFloat64ToUintPtr(d);
}
Convert<uintptr, intptr>(i: intptr): uintptr {
return Unsigned(i);
}
Convert<uintptr, RawPtr>(r: RawPtr): uintptr {
return Unsigned(r);
}
Convert<intptr, RawPtr>(r: RawPtr): intptr {
return Signed(r);
}
Convert<bint, int32>(v: int32): bint {
return IntPtrToBInt(Convert<intptr>(v));
}
extern macro IntPtrToBInt(intptr): bint;
Convert<bint, intptr>(v: intptr): bint {
return IntPtrToBInt(v);
}
extern macro SmiToBInt(Smi): bint;
Convert<bint, Smi>(v: Smi): bint {
return SmiToBInt(v);
}
macro BranchIf<A: type, B: type>(implicit context: Context)(o: B): never
labels True, False {
Cast<A>(o) otherwise False;
goto True;
}
macro BranchIfNot<A: type, B: type>(implicit context: Context)(o: B): never
labels True, False {
Cast<A>(o) otherwise True;
goto False;
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
}
macro Is<A: type, B: type>(implicit context: Context)(o: B): bool {
return (BranchIf<A, B>(o)) ? true : false;
}
macro UnsafeCast<A: type>(implicit context: Context)(o: Object): A {
assert(Is<A>(o));
return %RawObjectCast<A>(o);
}
UnsafeCast<Object>(o: Object): Object {
return o;
}
const kCOWMap: Map = %RawObjectCast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex));
const kEmptyFixedArray: FixedArrayBase =
%RawObjectCast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex));
extern macro IsPrototypeInitialArrayPrototype(implicit context: Context)(Map):
bool;
extern macro IsNoElementsProtectorCellInvalid(): bool;
extern macro IsArrayIteratorProtectorCellInvalid(): bool;
extern macro IsArraySpeciesProtectorCellInvalid(): bool;
extern macro IsTypedArraySpeciesProtectorCellInvalid(): bool;
extern macro IsPromiseSpeciesProtectorCellInvalid(): bool;
extern operator '.buffer' macro
TypedArrayBuiltinsAssembler::LoadTypedArrayBuffer(JSTypedArray): JSArrayBuffer;
extern operator '.data_ptr' macro TypedArrayBuiltinsAssembler::LoadDataPtr(
JSTypedArray): RawPtr;
extern operator '.elements_kind' macro LoadMapElementsKind(Map): ElementsKind;
extern operator '.elements_kind' macro LoadElementsKind(JSTypedArray):
ElementsKind;
extern operator '.elements' macro LoadElements(JSObject): FixedArrayBase;
extern operator '.elements=' macro StoreElements(JSObject, FixedArrayBase);
extern operator '.length' macro LoadJSTypedArrayLength(JSTypedArray): Smi;
extern operator '.length' macro LoadJSArrayLength(JSArray): Number;
extern operator '.length' macro LoadJSArgumentsObjectWithLength(
JSArgumentsObjectWithLength): Object;
extern operator '.length' macro LoadFastJSArrayLength(FastJSArray): Smi;
extern operator '.length=' macro StoreJSArrayLength(JSArray, Smi);
extern operator '.length' macro LoadFixedArrayBaseLength(FixedArrayBase): Smi;
extern operator '.length_intptr' macro LoadAndUntagFixedArrayBaseLength(
FixedArrayBase): intptr;
extern operator '[]' macro LoadFixedArrayElement(FixedArray, intptr): Object;
extern operator '[]' macro LoadFixedArrayElement(FixedArray, Smi): Object;
extern operator '[]' macro LoadFixedArrayElement(
FixedArray, constexpr int31): Object;
extern operator '[]=' macro StoreFixedArrayElement(
FixedArray, intptr, Smi): void;
extern operator '[]=' macro StoreFixedArrayElement(
FixedArray, intptr, HeapObject): void;
extern operator '[]=' macro StoreFixedArrayElement(
FixedArray, constexpr int31, Smi): void;
extern operator '[]=' macro StoreFixedArrayElement(
FixedArray, constexpr int31, HeapObject): void;
extern operator '[]=' macro StoreFixedArrayElementSmi(
FixedArray, Smi, Object): void;
operator '[]=' macro StoreFixedDoubleArrayNumber(
a: FixedDoubleArray, index: Smi, value: Number): void {
a[index] = Convert<float64>(value);
}
extern macro StoreFixedArrayElementSmi(
FixedArray, Smi, Object, constexpr WriteBarrierMode): void;
extern operator '.instance_type' macro LoadMapInstanceType(Map): int32;
extern operator '.prototype_or_initial_map' macro
LoadJSFunctionPrototypeOrInitialMap(JSFunction): Object;
extern macro LoadFixedDoubleArrayElement(FixedDoubleArray, Smi): float64;
extern macro Float64SilenceNaN(float64): float64;
extern macro StoreFixedDoubleArrayElement(
FixedDoubleArray, Object, float64, constexpr ParameterMode);
extern macro StoreFixedArrayElement(
FixedArray, intptr, Object, constexpr WriteBarrierMode): void;
macro StoreFixedDoubleArrayElementWithSmiIndex(
array: FixedDoubleArray, index: Smi, value: float64) {
StoreFixedDoubleArrayElement(array, index, value, SMI_PARAMETERS);
}
extern macro GetNumberDictionaryNumberOfElements(NumberDictionary): Smi;
extern macro BasicLoadNumberDictionaryElement(NumberDictionary, intptr): Object
labels NotData, IfHole;
extern macro BasicStoreNumberDictionaryElement(NumberDictionary, intptr, Object)
labels NotData, IfHole, ReadOnly;
extern macro IsFastElementsKind(ElementsKind): bool;
extern macro IsDoubleElementsKind(ElementsKind): bool;
extern macro IsFastSmiOrTaggedElementsKind(ElementsKind): bool;
extern macro IsFastSmiElementsKind(ElementsKind): bool;
extern macro IsHoleyFastElementsKind(ElementsKind): bool;
macro AllowDoubleElements(kind: ElementsKind): ElementsKind {
if (kind == PACKED_SMI_ELEMENTS) {
return PACKED_DOUBLE_ELEMENTS;
} else if (kind == HOLEY_SMI_ELEMENTS) {
return HOLEY_DOUBLE_ELEMENTS;
}
return kind;
}
macro AllowNonNumberElements(kind: ElementsKind): ElementsKind {
if (kind == PACKED_SMI_ELEMENTS) {
return PACKED_ELEMENTS;
} else if (kind == HOLEY_SMI_ELEMENTS) {
return HOLEY_ELEMENTS;
} else if (kind == PACKED_DOUBLE_ELEMENTS) {
return PACKED_ELEMENTS;
} else if (kind == HOLEY_DOUBLE_ELEMENTS) {
return HOLEY_ELEMENTS;
}
return kind;
}
extern macro AllocateZeroedFixedArray(intptr): FixedArray;
extern macro AllocateZeroedFixedDoubleArray(intptr): FixedDoubleArray;
extern macro CalculateNewElementsCapacity(Smi): Smi;
extern macro CalculateNewElementsCapacity(intptr): intptr;
extern macro AllocateFixedArrayWithHoles(
intptr, constexpr AllocationFlags): FixedArray;
extern macro CopyFixedArrayElements(
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray,
intptr, intptr, intptr): void;
extern macro CopyFixedArrayElements(
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, Smi,
Smi, Smi): void;
extern macro AllocateJSArray(constexpr ElementsKind, Map, intptr, Smi): JSArray;
extern macro AllocateJSArray(constexpr ElementsKind, Map, Smi, Smi): JSArray;
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
extern macro AllocateJSObjectFromMap(Map): JSObject;
extern operator '[]=' macro StoreFixedDoubleArrayElementSmi(
FixedDoubleArray, Smi, float64): void;
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, Smi): float64
labels IfHole;
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, intptr): float64
labels IfHole;
extern macro StoreFixedDoubleArrayHoleSmi(FixedDoubleArray, Smi): void;
macro GetObjectFunction(implicit context: Context)(): JSFunction {
return UnsafeCast<JSFunction>(
LoadNativeContext(context)[OBJECT_FUNCTION_INDEX]);
}
extern transitioning macro Call(Context, Callable, Object): Object;
extern transitioning macro Call(Context, Callable, Object, Object): Object;
extern transitioning macro Call(
Context, Callable, Object, Object, Object): Object;
extern transitioning macro Call(
Context, Callable, Object, Object, Object, Object): Object;
extern transitioning macro Call(
Context, Callable, Object, Object, Object, Object, Object): Object;
extern transitioning macro Call(
Context, Callable, Object, Object, Object, Object, Object, Object): Object;
extern builtin CloneFastJSArray(Context, FastJSArrayForCopy): JSArray;
extern macro ExtractFixedArray(FixedArrayBase, Smi, Smi, Smi): FixedArrayBase;
extern macro ExtractFixedArray(
FixedArrayBase, Smi, Smi, Smi,
constexpr ExtractFixedArrayFlags): FixedArrayBase;
extern macro ExtractFixedArray(
FixedArray, intptr, intptr, intptr,
constexpr ExtractFixedArrayFlags): FixedArray;
extern builtin ExtractFastJSArray(Context, JSArray, Smi, Smi): JSArray;
extern macro MoveElements(
constexpr ElementsKind, FixedArrayBase, intptr, intptr, intptr): void;
macro TorqueMoveElements(
elements: FixedArray, dstIndex: intptr, srcIndex: intptr,
count: intptr): void {
MoveElements(HOLEY_ELEMENTS, elements, dstIndex, srcIndex, count);
}
macro TorqueMoveElements(
elements: FixedDoubleArray, dstIndex: intptr, srcIndex: intptr,
count: intptr): void {
MoveElements(HOLEY_DOUBLE_ELEMENTS, elements, dstIndex, srcIndex, count);
}
extern macro CopyElements(
constexpr ElementsKind, FixedArrayBase, intptr, FixedArrayBase, intptr,
intptr): void;
macro TorqueCopyElements(
dstElements: FixedArray, dstIndex: intptr, srcElements: FixedArray,
srcIndex: intptr, count: intptr): void {
CopyElements(
HOLEY_ELEMENTS, dstElements, dstIndex, srcElements, srcIndex, count);
}
macro TorqueCopyElements(
dstElements: FixedDoubleArray, dstIndex: intptr,
srcElements: FixedDoubleArray, srcIndex: intptr, count: intptr): void {
CopyElements(
HOLEY_DOUBLE_ELEMENTS, dstElements, dstIndex, srcElements, srcIndex,
count);
}
macro LoadElementNoHole<T: type>(a: JSArray, index: Smi): Object
labels IfHole;
LoadElementNoHole<FixedArray>(implicit context: Context)(
a: JSArray, index: Smi): Object
labels IfHole {
try {
let elements: FixedArray =
Cast<FixedArray>(a.elements) otherwise Unexpected;
let e: Object = elements[index];
if (e == Hole) {
goto IfHole;
}
return e;
}
label Unexpected {
unreachable;
}
}
LoadElementNoHole<FixedDoubleArray>(implicit context: Context)(
a: JSArray, index: Smi): Object
labels IfHole {
try {
let elements: FixedDoubleArray =
Cast<FixedDoubleArray>(a.elements) otherwise Unexpected;
let e: float64 = LoadDoubleWithHoleCheck(elements, index) otherwise IfHole;
return AllocateHeapNumberWithValue(e);
}
label Unexpected {
unreachable;
}
}
extern macro TransitionElementsKind(
JSObject, Map, ElementsKind, ElementsKind): void labels Bailout;
extern macro IsCallable(HeapObject): bool;
extern macro IsJSArray(HeapObject): bool;
extern macro IsMap(HeapObject): bool;
extern macro IsJSFunction(HeapObject): bool;
extern macro IsJSObject(HeapObject): bool;
extern macro IsJSTypedArray(HeapObject): bool;
extern macro IsNumberDictionary(HeapObject): bool;
extern macro IsFixedTypedArray(HeapObject): bool;
extern macro IsContext(HeapObject): bool;
extern macro IsJSReceiver(HeapObject): bool;
extern macro TaggedIsCallable(Object): bool;
extern macro IsDetachedBuffer(JSArrayBuffer): bool;
extern macro IsHeapNumber(HeapObject): bool;
Reland ^2 "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" This is a reland of 9e48a24fd9b88712e4ec591c8b1fd40dc6381f18 Original change's description: > Reland "[array] Move Array.p.sort to Torque and use TimSort instead of QuickSort" > > The CL was reverted because it broke some tests in ChromeOS. > > > [array] Move Array.p.sort to Torque and use TimSort instead of QuickSort > > > > This CL changes the sorting algorithm used in Array.p.sort from > > QuickSort to TimSort (implemented in Torque). > > > > Detailed performance results can be found here: https://goo.gl/4E733J > > > > To save on code space, fast-paths are implemented as sets of > > function pointers instead of specializing generics. > > > > R=cbruni@chromium.org, jgruber@chromium.org > > > > Bug: v8:7382, v8:7624 > > Change-Id: I7cd4287e4562d84ab7c79c58ae30780630f976de > > Reviewed-on: https://chromium-review.googlesource.com/1151199 > > Commit-Queue: Simon Zünd <szuend@google.com> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Camillo Bruni <cbruni@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#55003} > > Bug: v8:7382, v8:7624 > Change-Id: Ic7a3230f3708177774b0760f08b7659d83ec5505 > Reviewed-on: https://chromium-review.googlesource.com/1184901 > Commit-Queue: Simon Zünd <szuend@google.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#55325} Bug: v8:7382, v8:7624 Change-Id: I297611f45c09967e0f6961156b0c9ebdebc7053f Reviewed-on: https://chromium-review.googlesource.com/1186801 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/master@{#55360}
2018-08-22 13:17:38 +00:00
extern macro IsFixedArray(HeapObject): bool;
extern macro IsNumber(Object): bool;
extern macro IsJSArrayMap(Map): bool;
extern macro IsExtensibleMap(Map): bool;
extern macro IsCustomElementsReceiverInstanceType(int32): bool;
Reland "[builtins] Implement Object.fromEntries" This is a reland of a5336471f273a9061f1a03fdad9d78214d81a793 Original change's description: > [builtins] Implement Object.fromEntries > > Adds the Object.fromEntries() method behind > --harmony-object-from-entries. > > 
> Includes an initial implementation of the new experimental builtin > Object.fromEntries implemented by Daniel Clifford, and > has been modified by Caitlin Potter to support a fast case to skip > the iterator protocol when it can be done unobservably in common cases. > > There are some incidental changes: A number of CSA macros have been > updated to use TNodes, and some Context arguments have been > re-arranged to be implicit in Torque.
> > > There are also a number of mjsunit tests written mirroring and > expanding on the test262 tests. > > BUG=v8:8021 > > Change-Id: I1c12bee8a2f98c6297b77d5d723910a5e3b630cc > Co-authored-by: Daniel Clifford <danno@chromium.org> > Co-authored-by: Caitlin Potter <caitp@igalia.com> > Reviewed-on: https://chromium-review.googlesource.com/c/1337585 > Commit-Queue: Daniel Clifford <danno@chromium.org> > Reviewed-by: Daniel Clifford <danno@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#57667} Bug: v8:8021 Change-Id: I706e2d87bfc2f688e833c1b7d40ca82f5d80f5a2 Reviewed-on: https://chromium-review.googlesource.com/c/1346630 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Caitlin Potter <caitp@igalia.com> Cr-Commit-Position: refs/heads/master@{#57798}
2018-11-22 15:29:55 +00:00
extern macro IsFastJSArrayWithNoCustomIteration(implicit context: Context)(
Object): bool;
extern macro Typeof(Object): Object;
// Return true iff number is NaN.
macro NumberIsNaN(number: Number): bool {
typeswitch (number) {
case (Smi): {
[torque] add typeswitch statement This adds a typeswitch statement typeswitch (e) case (x1 : Type1) { ... } case (x2 : Type2) { } ... ... case (xn : TypeN) { ... } This checks to which of the given types the result of evaluating e can be cast, in the order in which they are listed. So if an earlier type matches, a value of this type won't reach a later case. The type-checks are performed by calling the cast<T>() macro. The type of the argument passed to the cast macro is dependent on the case and excludes all types checked earlier. For example, in const x : Object = ... typeswitch (x) case (x : Smi) { ... } case (x : HeapNumber) { ... } case (x : HeapObject) { ... } there will be calls to cast<Smi>(Object) and cast<HeapNumber>(HeapObject), because after the Smi check we know that x has to be a HeapObject. With the refactored base.tq definition of cast, this will generate efficient code and avoid repeating the Smi check in the second case. The type system ensures that all cases are reachable and that the type given to the last case is safe without a runtime check (in other words, the union of all checked types covers the type of e). The cases can also be written as case (Type) { ... } , in which case the switched value is not re-bound with the checked type. Bug: v8:7793 Change-Id: Iea4aed7465d62b445e3ae0d33f52921912e095e3 Reviewed-on: https://chromium-review.googlesource.com/1156506 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Daniel Clifford <danno@chromium.org> Cr-Commit-Position: refs/heads/master@{#54958}
2018-08-07 21:57:19 +00:00
return false;
}
case (hn: HeapNumber): {
let value: float64 = Convert<float64>(hn);
return value != value;
}
}
}
extern macro GotoIfForceSlowPath() labels Taken;
extern macro BranchIfToBooleanIsTrue(Object): never
labels Taken, NotTaken;
macro ToBoolean(obj: Object): bool {
if (BranchIfToBooleanIsTrue(obj)) {
return true;
} else {
return false;
}
}
macro ToIndex(input: Object, context: Context): Number
labels RangeError {
if (input == Undefined) {
return 0;
}
let value: Number = ToInteger_Inline(context, input, kTruncateMinusZero);
if (value < 0 || value > kMaxSafeInteger) {
goto RangeError;
}
return value;
}
transitioning macro GetLengthProperty(implicit context: Context)(o: Object):
Number {
try {
typeswitch (o) {
case (a: JSArray): {
return a.length;
}
case (a: JSArgumentsObjectWithLength): {
goto ToLength(a.length);
}
case (Object): deferred {
goto ToLength(GetProperty(o, kLengthString));
}
}
}
label ToLength(length: Object) deferred {
return ToLength_Inline(context, length);
}
}
extern macro NumberToString(Number): String;
extern macro HasOnlyOneByteChars(InstanceType): bool;
extern macro AllocateSeqOneByteString(implicit context: Context)(uint32):
String;
extern macro AllocateSeqTwoByteString(implicit context: Context)(uint32):
String;
extern macro TryIntPtrAdd(intptr, intptr): intptr
labels IfOverflow;
extern builtin ObjectToString(Context, Object): Object;
Reland "[builtins] Fix Array.p.join length overflow and invalid string length handling" This is a reland of ec969ea3b18eeba7d9deea09142da8b6d882a4af Temporarily removes high memory usage test. Original change's description: > [builtins] Fix Array.p.join length overflow and invalid string length handling > > - Fixes and simplify allocating the temporary fixed array for ToString-ed elements. > - When the array size is greater than representable by an intptr, it overflowed into a negative value causing a non-negative assert to fail. > - Simplify fallback behavior by always allocating a conservatively sized temporary fixed array. Previously, if the array had dictionary elements, the temporary fixed array was sized based on %GetNumberDictionaryNumberOfElements() and then resized when entering the fallback. > > - Fixes related invalid string length handling. When the running total of the resulting string length overflowed or exceeded String::kMaxLength, a RangeError is thrown. Previously, this thrown RangeError bypassed JoinStackPop and left the receiver on the stack. > > Bug: chromium:897404 > Change-Id: I157b71ef04ab06125a5b1c3454e5ed3713bdb591 > Reviewed-on: https://chromium-review.googlesource.com/c/1293070 > Commit-Queue: Peter Wong <peter.wm.wong@gmail.com> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#56907} Bug: chromium:897404 Change-Id: I4995893f6f9724b26c231d05619ad65dbccc7223 Reviewed-on: https://chromium-review.googlesource.com/c/1297675 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Peter Wong <peter.wm.wong@gmail.com> Cr-Commit-Position: refs/heads/master@{#56946}
2018-10-24 12:25:09 +00:00
extern builtin StringRepeat(Context, String, Number): String;
struct KeyValuePair {
key: Object;
value: Object;
}
// Macro definitions for compatibility that expose functionality to the CSA
// using "legacy" APIs. In Torque code, these should not be used.
macro IsFastJSArray(o: Object, context: Context): bool {
try {
// Long-term, it's likely not a good idea to have this slow-path test here,
// since it fundamentally breaks the type system.
GotoIfForceSlowPath() otherwise ForceSlow;
}
label ForceSlow {
return false;
}
return Is<FastJSArray>(o);
}
macro BranchIfFastJSArray(o: Object, context: Context): never
labels True, False {
// Long-term, it's likely not a good idea to have this slow-path test here,
// since it fundamentally breaks the type system.
GotoIfForceSlowPath() otherwise False;
BranchIf<FastJSArray>(o) otherwise True, False;
}
macro BranchIfNotFastJSArray(o: Object, context: Context): never
labels True, False {
BranchIfNot<FastJSArray>(o) otherwise True, False;
}
macro BranchIfFastJSArrayForCopy(o: Object, context: Context): never
labels True, False {
// Long-term, it's likely not a good idea to have this slow-path test here,
// since it fundamentally breaks the type system.
GotoIfForceSlowPath() otherwise False;
BranchIf<FastJSArrayForCopy>(o) otherwise True, False;
}
macro IsFastJSArrayWithNoCustomIteration(context: Context, o: Object): bool {
return Is<FastJSArrayWithNoCustomIteration>(o);
}