Commit 17a18084 authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Don't crash when typing load from a Uint8ClampedArray.

TEST=mjsunit/compiler/regress-446156
BUG=chromium:446156
LOG=y
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/835883003

Cr-Commit-Position: refs/heads/master@{#25957}
parent c329a49d
......@@ -33,10 +33,11 @@ enum LazyCachedType {
kImulFunc,
kClz32Func,
kArrayBufferFunc,
#define NATIVE_TYPE_CASE(Type) k##Type, k##Type##Array, k##Type##ArrayFunc,
NATIVE_TYPES(NATIVE_TYPE_CASE)
#undef NATIVE_TYPE_CASE
kNumLazyCachedTypes
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
k##Type, k##Type##Array, k##Type##ArrayFunc,
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
kNumLazyCachedTypes
};
......@@ -75,6 +76,8 @@ class LazyTypeCache FINAL : public ZoneObject {
return CreateNative(Type::Number(), Type::UntaggedFloat32());
case kFloat64:
return CreateNative(Type::Number(), Type::UntaggedFloat64());
case kUint8Clamped:
return Get(kUint8);
case kNumberFunc0:
return Type::Function(Type::Number(), zone());
case kNumberFunc1:
......@@ -89,13 +92,13 @@ class LazyTypeCache FINAL : public ZoneObject {
return Type::Function(CreateRange(0, 32), Type::Number(), zone());
case kArrayBufferFunc:
return Type::Function(Type::Object(zone()), Type::Unsigned32(), zone());
#define NATIVE_TYPE_CASE(Type) \
case k##Type##Array: \
return CreateArray(Get(k##Type)); \
case k##Type##ArrayFunc: \
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case k##Type##Array: \
return CreateArray(Get(k##Type)); \
case k##Type##ArrayFunc: \
return CreateArrayFunction(Get(k##Type##Array));
NATIVE_TYPES(NATIVE_TYPE_CASE)
#undef NATIVE_TYPE_CASE
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
case kNumLazyCachedTypes:
break;
}
......@@ -1615,13 +1618,11 @@ Bounds Typer::Visitor::TypeLoadBuffer(Node* node) {
// TODO(bmeurer): This typing is not yet correct. Since we can still access
// out of bounds, the type in the general case has to include Undefined.
switch (BufferAccessOf(node->op()).external_array_type()) {
#define NATIVE_TYPE_CASE(Type) \
case kExternal##Type##Array: \
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case kExternal##Type##Array: \
return Bounds(typer_->cache_->Get(k##Type));
NATIVE_TYPES(NATIVE_TYPE_CASE)
#undef NATIVE_TYPE_CASE
case kExternalUint8ClampedArray:
break;
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
UNREACHABLE();
return Bounds();
......@@ -2088,14 +2089,11 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
}
} else if (value->IsJSTypedArray()) {
switch (JSTypedArray::cast(*value)->type()) {
#define NATIVE_TYPE_CASE(Type) \
case kExternal##Type##Array: \
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case kExternal##Type##Array: \
return typer_->cache_->Get(k##Type##Array);
NATIVE_TYPES(NATIVE_TYPE_CASE)
#undef NATIVE_TYPE_CASE
case kExternalUint8ClampedArray:
// TODO(rossberg): Do we want some ClampedArray type to express this?
break;
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
}
return Type::Constant(value, zone());
......
// Copyright 2015 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.
(function Module(stdlib, foreign, heap) {
"use asm";
// This is not valid asm.js, but should nevertheless work.
var MEM = new Uint8ClampedArray(heap);
function foo( ) { MEM[0] ^= 1; }
return {foo: foo};
})(this, {}, new ArrayBuffer( ) ).foo();
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