OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/builtins/builtins-promise.h" | 6 #include "src/builtins/builtins-promise.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 | 1999 |
2000 FunctionTester ft(code, kNumParams); | 2000 FunctionTester ft(code, kNumParams); |
2001 Handle<Object> result_obj = | 2001 Handle<Object> result_obj = |
2002 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); | 2002 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); |
2003 CHECK(result_obj->IsFixedArray()); | 2003 CHECK(result_obj->IsFixedArray()); |
2004 Handle<FixedArray> result_arr = Handle<FixedArray>::cast(result_obj); | 2004 Handle<FixedArray> result_arr = Handle<FixedArray>::cast(result_obj); |
2005 CHECK(result_arr->get(0)->IsJSFunction()); | 2005 CHECK(result_arr->get(0)->IsJSFunction()); |
2006 CHECK(result_arr->get(1)->IsJSFunction()); | 2006 CHECK(result_arr->get(1)->IsJSFunction()); |
2007 } | 2007 } |
2008 | 2008 |
| 2009 TEST(NewElementsCapacity) { |
| 2010 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 2011 CodeAssemblerTester data(isolate, 1); |
| 2012 CodeStubAssembler m(data.state()); |
| 2013 m.Return(m.SmiTag(m.CalculateNewElementsCapacity( |
| 2014 m.SmiUntag(m.Parameter(0)), CodeStubAssembler::INTPTR_PARAMETERS))); |
| 2015 Handle<Code> code = data.GenerateCode(); |
| 2016 CHECK(!code.is_null()); |
| 2017 FunctionTester ft(code, 1); |
| 2018 Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate); |
| 2019 Handle<Smi> result_obj = |
| 2020 Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2021 CHECK_EQ( |
| 2022 result_obj->value(), |
| 2023 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2024 test_value = Handle<Smi>(Smi::FromInt(1), isolate); |
| 2025 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2026 CHECK_EQ( |
| 2027 result_obj->value(), |
| 2028 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2029 test_value = Handle<Smi>(Smi::FromInt(2), isolate); |
| 2030 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2031 CHECK_EQ( |
| 2032 result_obj->value(), |
| 2033 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2034 test_value = Handle<Smi>(Smi::FromInt(1025), isolate); |
| 2035 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2036 CHECK_EQ( |
| 2037 result_obj->value(), |
| 2038 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2039 } |
| 2040 |
| 2041 TEST(NewElementsCapacitySmi) { |
| 2042 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 2043 CodeAssemblerTester data(isolate, 1); |
| 2044 CodeStubAssembler m(data.state()); |
| 2045 m.Return(m.CalculateNewElementsCapacity(m.Parameter(0), |
| 2046 CodeStubAssembler::SMI_PARAMETERS)); |
| 2047 Handle<Code> code = data.GenerateCode(); |
| 2048 CHECK(!code.is_null()); |
| 2049 FunctionTester ft(code, 1); |
| 2050 Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate); |
| 2051 Handle<Smi> result_obj = |
| 2052 Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2053 CHECK_EQ( |
| 2054 result_obj->value(), |
| 2055 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2056 test_value = Handle<Smi>(Smi::FromInt(1), isolate); |
| 2057 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2058 CHECK_EQ( |
| 2059 result_obj->value(), |
| 2060 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2061 test_value = Handle<Smi>(Smi::FromInt(2), isolate); |
| 2062 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2063 CHECK_EQ( |
| 2064 result_obj->value(), |
| 2065 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2066 test_value = Handle<Smi>(Smi::FromInt(1025), isolate); |
| 2067 result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked()); |
| 2068 CHECK_EQ( |
| 2069 result_obj->value(), |
| 2070 static_cast<int>(JSObject::NewElementsCapacity(test_value->value()))); |
| 2071 } |
| 2072 |
2009 TEST(AllocateFunctionWithMapAndContext) { | 2073 TEST(AllocateFunctionWithMapAndContext) { |
2010 Isolate* isolate(CcTest::InitIsolateOnce()); | 2074 Isolate* isolate(CcTest::InitIsolateOnce()); |
2011 | 2075 |
2012 const int kNumParams = 1; | 2076 const int kNumParams = 1; |
2013 CodeAssemblerTester data(isolate, kNumParams); | 2077 CodeAssemblerTester data(isolate, kNumParams); |
2014 PromiseBuiltinsAssembler m(data.state()); | 2078 PromiseBuiltinsAssembler m(data.state()); |
2015 | 2079 |
2016 Node* const context = m.Parameter(kNumParams + 2); | 2080 Node* const context = m.Parameter(kNumParams + 2); |
2017 Node* const native_context = m.LoadNativeContext(context); | 2081 Node* const native_context = m.LoadNativeContext(context); |
2018 Node* const promise = | 2082 Node* const promise = |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 .ToHandleChecked(); | 2252 .ToHandleChecked(); |
2189 Handle<Object> prop2 = | 2253 Handle<Object> prop2 = |
2190 JSReceiver::GetProperty(isolate, promise, "rejectedReason") | 2254 JSReceiver::GetProperty(isolate, promise, "rejectedReason") |
2191 .ToHandleChecked(); | 2255 .ToHandleChecked(); |
2192 CHECK_EQ(*rejected_str, *prop2); | 2256 CHECK_EQ(*rejected_str, *prop2); |
2193 } | 2257 } |
2194 } | 2258 } |
2195 | 2259 |
2196 } // namespace internal | 2260 } // namespace internal |
2197 } // namespace v8 | 2261 } // namespace v8 |
OLD | NEW |