Commit 506d49fb authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] require exact match in return type for cast-like operations

This fixes the bug that cast<A>(...) could be interpreted as
cast<B>(...) if B is a subtype of A.

Bug: v8:7793

Change-Id: Ia03ce832f8c14ced09114d41c935be06d4629d99
Reviewed-on: https://chromium-review.googlesource.com/1075890
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53397}
parent 0a373f8a
...@@ -231,6 +231,8 @@ extern operator 'cast<>' macro ConvertFixedArrayBaseToFixedArray( ...@@ -231,6 +231,8 @@ extern operator 'cast<>' macro ConvertFixedArrayBaseToFixedArray(
FixedArrayBase): FixedArray labels CastError; FixedArrayBase): FixedArray labels CastError;
extern operator 'cast<>' macro ConvertFixedArrayBaseToFixedDoubleArray( extern operator 'cast<>' macro ConvertFixedArrayBaseToFixedDoubleArray(
FixedArrayBase): FixedDoubleArray labels CastError; FixedArrayBase): FixedDoubleArray labels CastError;
extern operator 'cast<>' macro TaggedToNumber(
Object): Number labels CastError;
extern macro AllocateHeapNumberWithValue(float64): HeapNumber; extern macro AllocateHeapNumberWithValue(float64): HeapNumber;
......
...@@ -163,6 +163,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -163,6 +163,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
return UncheckedCast<Smi>(value); return UncheckedCast<Smi>(value);
} }
TNode<Number> TaggedToNumber(TNode<Object> value, Label* fail) {
GotoIfNot(IsNumber(value), fail);
return UncheckedCast<Number>(value);
}
TNode<HeapObject> TaggedToHeapObject(TNode<Object> value, Label* fail) { TNode<HeapObject> TaggedToHeapObject(TNode<Object> value, Label* fail) {
GotoIf(TaggedIsSmi(value), fail); GotoIf(TaggedIsSmi(value), fail);
return UncheckedCast<HeapObject>(value); return UncheckedCast<HeapObject>(value);
......
...@@ -1092,8 +1092,7 @@ VisitResult ImplementationVisitor::GenerateOperation( ...@@ -1092,8 +1092,7 @@ VisitResult ImplementationVisitor::GenerateOperation(
} }
} }
if (!return_type || (GetTypeOracle().IsAssignableFrom( if (!return_type || return_type == handler.result_type) {
*return_type, handler.result_type))) {
return GenerateCall(handler.macro_name, arguments, false); return GenerateCall(handler.macro_name, arguments, false);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment