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 { ...@@ -33,10 +33,11 @@ enum LazyCachedType {
kImulFunc, kImulFunc,
kClz32Func, kClz32Func,
kArrayBufferFunc, kArrayBufferFunc,
#define NATIVE_TYPE_CASE(Type) k##Type, k##Type##Array, k##Type##ArrayFunc, #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
NATIVE_TYPES(NATIVE_TYPE_CASE) k##Type, k##Type##Array, k##Type##ArrayFunc,
#undef NATIVE_TYPE_CASE TYPED_ARRAYS(TYPED_ARRAY_CASE)
kNumLazyCachedTypes #undef TYPED_ARRAY_CASE
kNumLazyCachedTypes
}; };
...@@ -75,6 +76,8 @@ class LazyTypeCache FINAL : public ZoneObject { ...@@ -75,6 +76,8 @@ class LazyTypeCache FINAL : public ZoneObject {
return CreateNative(Type::Number(), Type::UntaggedFloat32()); return CreateNative(Type::Number(), Type::UntaggedFloat32());
case kFloat64: case kFloat64:
return CreateNative(Type::Number(), Type::UntaggedFloat64()); return CreateNative(Type::Number(), Type::UntaggedFloat64());
case kUint8Clamped:
return Get(kUint8);
case kNumberFunc0: case kNumberFunc0:
return Type::Function(Type::Number(), zone()); return Type::Function(Type::Number(), zone());
case kNumberFunc1: case kNumberFunc1:
...@@ -89,13 +92,13 @@ class LazyTypeCache FINAL : public ZoneObject { ...@@ -89,13 +92,13 @@ class LazyTypeCache FINAL : public ZoneObject {
return Type::Function(CreateRange(0, 32), Type::Number(), zone()); return Type::Function(CreateRange(0, 32), Type::Number(), zone());
case kArrayBufferFunc: case kArrayBufferFunc:
return Type::Function(Type::Object(zone()), Type::Unsigned32(), zone()); return Type::Function(Type::Object(zone()), Type::Unsigned32(), zone());
#define NATIVE_TYPE_CASE(Type) \ #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case k##Type##Array: \ case k##Type##Array: \
return CreateArray(Get(k##Type)); \ return CreateArray(Get(k##Type)); \
case k##Type##ArrayFunc: \ case k##Type##ArrayFunc: \
return CreateArrayFunction(Get(k##Type##Array)); return CreateArrayFunction(Get(k##Type##Array));
NATIVE_TYPES(NATIVE_TYPE_CASE) TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef NATIVE_TYPE_CASE #undef TYPED_ARRAY_CASE
case kNumLazyCachedTypes: case kNumLazyCachedTypes:
break; break;
} }
...@@ -1615,13 +1618,11 @@ Bounds Typer::Visitor::TypeLoadBuffer(Node* node) { ...@@ -1615,13 +1618,11 @@ Bounds Typer::Visitor::TypeLoadBuffer(Node* node) {
// TODO(bmeurer): This typing is not yet correct. Since we can still access // 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. // out of bounds, the type in the general case has to include Undefined.
switch (BufferAccessOf(node->op()).external_array_type()) { switch (BufferAccessOf(node->op()).external_array_type()) {
#define NATIVE_TYPE_CASE(Type) \ #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case kExternal##Type##Array: \ case kExternal##Type##Array: \
return Bounds(typer_->cache_->Get(k##Type)); return Bounds(typer_->cache_->Get(k##Type));
NATIVE_TYPES(NATIVE_TYPE_CASE) TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef NATIVE_TYPE_CASE #undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
break;
} }
UNREACHABLE(); UNREACHABLE();
return Bounds(); return Bounds();
...@@ -2088,14 +2089,11 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) { ...@@ -2088,14 +2089,11 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
} }
} else if (value->IsJSTypedArray()) { } else if (value->IsJSTypedArray()) {
switch (JSTypedArray::cast(*value)->type()) { switch (JSTypedArray::cast(*value)->type()) {
#define NATIVE_TYPE_CASE(Type) \ #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case kExternal##Type##Array: \ case kExternal##Type##Array: \
return typer_->cache_->Get(k##Type##Array); return typer_->cache_->Get(k##Type##Array);
NATIVE_TYPES(NATIVE_TYPE_CASE) TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef NATIVE_TYPE_CASE #undef TYPED_ARRAY_CASE
case kExternalUint8ClampedArray:
// TODO(rossberg): Do we want some ClampedArray type to express this?
break;
} }
} }
return Type::Constant(value, zone()); 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