OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/flags.h" | 5 #include "src/base/flags.h" |
6 #include "src/bootstrapper.h" | 6 #include "src/bootstrapper.h" |
7 #include "src/compiler/graph-reducer.h" | 7 #include "src/compiler/graph-reducer.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
11 #include "src/compiler/simplified-operator.h" | 11 #include "src/compiler/simplified-operator.h" |
12 #include "src/compiler/typer.h" | 12 #include "src/compiler/typer.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 #define NATIVE_TYPES(V) \ | 18 #define NATIVE_TYPES(V) \ |
19 V(Int8) \ | 19 V(Int8) \ |
20 V(Uint8) \ | 20 V(Uint8) \ |
21 V(Int16) \ | 21 V(Int16) \ |
22 V(Uint16) \ | 22 V(Uint16) \ |
23 V(Int32) \ | 23 V(Int32) \ |
24 V(Uint32) \ | 24 V(Uint32) \ |
25 V(Float32) \ | 25 V(Float32) \ |
26 V(Float64) | 26 V(Float64) |
27 | 27 |
28 enum LazyCachedType { | 28 enum LazyCachedType { |
| 29 kAnyFunc0, |
| 30 kAnyFunc1, |
| 31 kAnyFunc2, |
| 32 kAnyFunc3, |
29 kNumberFunc0, | 33 kNumberFunc0, |
30 kNumberFunc1, | 34 kNumberFunc1, |
31 kNumberFunc2, | 35 kNumberFunc2, |
32 kImulFunc, | 36 kImulFunc, |
33 kClz32Func, | 37 kClz32Func, |
34 kArrayBufferFunc, | 38 kArrayBufferFunc, |
35 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 39 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
36 k##Type, k##Type##Array, k##Type##ArrayFunc, | 40 k##Type, k##Type##Array, k##Type##ArrayFunc, |
37 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 41 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
38 #undef TYPED_ARRAY_CASE | 42 #undef TYPED_ARRAY_CASE |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 case kInt32: | 75 case kInt32: |
72 return CreateNative(Type::Signed32(), Type::UntaggedSigned32()); | 76 return CreateNative(Type::Signed32(), Type::UntaggedSigned32()); |
73 case kUint32: | 77 case kUint32: |
74 return CreateNative(Type::Unsigned32(), Type::UntaggedUnsigned32()); | 78 return CreateNative(Type::Unsigned32(), Type::UntaggedUnsigned32()); |
75 case kFloat32: | 79 case kFloat32: |
76 return CreateNative(Type::Number(), Type::UntaggedFloat32()); | 80 return CreateNative(Type::Number(), Type::UntaggedFloat32()); |
77 case kFloat64: | 81 case kFloat64: |
78 return CreateNative(Type::Number(), Type::UntaggedFloat64()); | 82 return CreateNative(Type::Number(), Type::UntaggedFloat64()); |
79 case kUint8Clamped: | 83 case kUint8Clamped: |
80 return Get(kUint8); | 84 return Get(kUint8); |
| 85 case kAnyFunc0: |
| 86 return Type::Function(Type::Any(), zone()); |
| 87 case kAnyFunc1: |
| 88 return Type::Function(Type::Any(), Type::Any(), zone()); |
| 89 case kAnyFunc2: |
| 90 return Type::Function(Type::Any(), Type::Any(), Type::Any(), zone()); |
| 91 case kAnyFunc3: |
| 92 return Type::Function(Type::Any(), Type::Any(), Type::Any(), |
| 93 Type::Any(), zone()); |
81 case kNumberFunc0: | 94 case kNumberFunc0: |
82 return Type::Function(Type::Number(), zone()); | 95 return Type::Function(Type::Number(), zone()); |
83 case kNumberFunc1: | 96 case kNumberFunc1: |
84 return Type::Function(Type::Number(), Type::Number(), zone()); | 97 return Type::Function(Type::Number(), Type::Number(), zone()); |
85 case kNumberFunc2: | 98 case kNumberFunc2: |
86 return Type::Function(Type::Number(), Type::Number(), Type::Number(), | 99 return Type::Function(Type::Number(), Type::Number(), Type::Number(), |
87 zone()); | 100 zone()); |
88 case kImulFunc: | 101 case kImulFunc: |
89 return Type::Function(Type::Signed32(), Type::Integral32(), | 102 return Type::Function(Type::Signed32(), Type::Integral32(), |
90 Type::Integral32(), zone()); | 103 Type::Integral32(), zone()); |
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 } else if (*value == native->uint16_array_fun()) { | 2399 } else if (*value == native->uint16_array_fun()) { |
2387 return typer_->cache_->Get(kUint16ArrayFunc); | 2400 return typer_->cache_->Get(kUint16ArrayFunc); |
2388 } else if (*value == native->uint32_array_fun()) { | 2401 } else if (*value == native->uint32_array_fun()) { |
2389 return typer_->cache_->Get(kUint32ArrayFunc); | 2402 return typer_->cache_->Get(kUint32ArrayFunc); |
2390 } else if (*value == native->float32_array_fun()) { | 2403 } else if (*value == native->float32_array_fun()) { |
2391 return typer_->cache_->Get(kFloat32ArrayFunc); | 2404 return typer_->cache_->Get(kFloat32ArrayFunc); |
2392 } else if (*value == native->float64_array_fun()) { | 2405 } else if (*value == native->float64_array_fun()) { |
2393 return typer_->cache_->Get(kFloat64ArrayFunc); | 2406 return typer_->cache_->Get(kFloat64ArrayFunc); |
2394 } | 2407 } |
2395 } | 2408 } |
| 2409 int const arity = |
| 2410 JSFunction::cast(*value)->shared()->internal_formal_parameter_count(); |
| 2411 switch (arity) { |
| 2412 case 0: |
| 2413 return typer_->cache_->Get(kAnyFunc0); |
| 2414 case 1: |
| 2415 return typer_->cache_->Get(kAnyFunc1); |
| 2416 case 2: |
| 2417 return typer_->cache_->Get(kAnyFunc2); |
| 2418 case 3: |
| 2419 return typer_->cache_->Get(kAnyFunc3); |
| 2420 default: { |
| 2421 Type** const params = zone()->NewArray<Type*>(arity); |
| 2422 std::fill(¶ms[0], ¶ms[arity], Type::Any(zone())); |
| 2423 return Type::Function(Type::Any(zone()), arity, params, zone()); |
| 2424 } |
| 2425 } |
2396 } else if (value->IsJSTypedArray()) { | 2426 } else if (value->IsJSTypedArray()) { |
2397 switch (JSTypedArray::cast(*value)->type()) { | 2427 switch (JSTypedArray::cast(*value)->type()) { |
2398 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 2428 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
2399 case kExternal##Type##Array: \ | 2429 case kExternal##Type##Array: \ |
2400 return typer_->cache_->Get(k##Type##Array); | 2430 return typer_->cache_->Get(k##Type##Array); |
2401 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2431 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2402 #undef TYPED_ARRAY_CASE | 2432 #undef TYPED_ARRAY_CASE |
2403 } | 2433 } |
2404 } | 2434 } |
2405 return Type::Constant(value, zone()); | 2435 return Type::Constant(value, zone()); |
2406 } | 2436 } |
2407 | 2437 |
2408 } // namespace compiler | 2438 } // namespace compiler |
2409 } // namespace internal | 2439 } // namespace internal |
2410 } // namespace v8 | 2440 } // namespace v8 |
OLD | NEW |