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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "test/cctest/test-api.h" | 8 #include "test/cctest/test-api.h" |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } | 1372 } |
1373 | 1373 |
1374 | 1374 |
1375 TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { | 1375 TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { |
1376 CcTest::InitializeVM(); | 1376 CcTest::InitializeVM(); |
1377 v8::HandleScope scope(CcTest::isolate()); | 1377 v8::HandleScope scope(CcTest::isolate()); |
1378 | 1378 |
1379 struct TestConfig { | 1379 struct TestConfig { |
1380 Handle<JSFunction> js_func1_; | 1380 Handle<JSFunction> js_func1_; |
1381 Handle<JSFunction> js_func2_; | 1381 Handle<JSFunction> js_func2_; |
| 1382 Handle<FieldType> function_type_; |
1382 TestConfig() { | 1383 TestConfig() { |
1383 Isolate* isolate = CcTest::i_isolate(); | 1384 Isolate* isolate = CcTest::i_isolate(); |
1384 Factory* factory = isolate->factory(); | 1385 Factory* factory = isolate->factory(); |
1385 js_func1_ = factory->NewFunction(factory->empty_string()); | 1386 Handle<String> name = factory->empty_string(); |
1386 js_func2_ = factory->NewFunction(factory->empty_string()); | 1387 Handle<Map> sloppy_map = |
| 1388 factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); |
| 1389 Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo( |
| 1390 name, MaybeHandle<Code>(), sloppy_map->is_constructor()); |
| 1391 function_type_ = FieldType::Class(sloppy_map, isolate); |
| 1392 CHECK(sloppy_map->is_stable()); |
| 1393 |
| 1394 js_func1_ = |
| 1395 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
| 1396 |
| 1397 js_func2_ = |
| 1398 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
1387 } | 1399 } |
1388 | 1400 |
1389 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1401 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
1390 Handle<Map> map) { | 1402 Handle<Map> map) { |
1391 CHECK(branch_id == 1 || branch_id == 2); | 1403 CHECK(branch_id == 1 || branch_id == 2); |
1392 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; | 1404 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; |
1393 return expectations.AddDataConstant(map, NONE, js_func); | 1405 return expectations.AddDataConstant(map, NONE, js_func); |
1394 } | 1406 } |
1395 | 1407 |
1396 void UpdateExpectations(int property_index, Expectations& expectations) { | 1408 void UpdateExpectations(int property_index, Expectations& expectations) { |
1397 Isolate* isolate = CcTest::i_isolate(); | |
1398 Handle<FieldType> function_type = | |
1399 FieldType::Class(isolate->sloppy_function_map(), isolate); | |
1400 expectations.SetDataField(property_index, Representation::HeapObject(), | 1409 expectations.SetDataField(property_index, Representation::HeapObject(), |
1401 function_type); | 1410 function_type_); |
1402 } | 1411 } |
1403 }; | 1412 }; |
1404 | 1413 |
1405 TestConfig config; | 1414 TestConfig config; |
1406 // Two branches are "incompatible" so the |map1| should be deprecated. | 1415 // Two branches are "incompatible" so the |map1| should be deprecated. |
1407 CheckDeprecated checker; | 1416 CheckDeprecated checker; |
1408 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1417 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
1409 } | 1418 } |
1410 | 1419 |
1411 | 1420 |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 SameMapChecker checker; | 2367 SameMapChecker checker; |
2359 TestTransitionTo(transition_op, transition_op, checker); | 2368 TestTransitionTo(transition_op, transition_op, checker); |
2360 } | 2369 } |
2361 | 2370 |
2362 | 2371 |
2363 TEST(TransitionDataConstantToAnotherDataConstant) { | 2372 TEST(TransitionDataConstantToAnotherDataConstant) { |
2364 CcTest::InitializeVM(); | 2373 CcTest::InitializeVM(); |
2365 v8::HandleScope scope(CcTest::isolate()); | 2374 v8::HandleScope scope(CcTest::isolate()); |
2366 Isolate* isolate = CcTest::i_isolate(); | 2375 Isolate* isolate = CcTest::i_isolate(); |
2367 Factory* factory = isolate->factory(); | 2376 Factory* factory = isolate->factory(); |
2368 Handle<FieldType> function_type = | 2377 Handle<String> name = factory->empty_string(); |
2369 FieldType::Class(isolate->sloppy_function_map(), isolate); | 2378 Handle<Map> sloppy_map = |
| 2379 factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); |
| 2380 Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo( |
| 2381 name, MaybeHandle<Code>(), sloppy_map->is_constructor()); |
| 2382 Handle<FieldType> function_type = FieldType::Class(sloppy_map, isolate); |
| 2383 CHECK(sloppy_map->is_stable()); |
2370 | 2384 |
2371 Handle<JSFunction> js_func1 = factory->NewFunction(factory->empty_string()); | 2385 Handle<JSFunction> js_func1 = |
| 2386 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
2372 TransitionToDataConstantOperator transition_op1(js_func1); | 2387 TransitionToDataConstantOperator transition_op1(js_func1); |
2373 | 2388 |
2374 Handle<JSFunction> js_func2 = factory->NewFunction(factory->empty_string()); | 2389 Handle<JSFunction> js_func2 = |
| 2390 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
2375 TransitionToDataConstantOperator transition_op2(js_func2); | 2391 TransitionToDataConstantOperator transition_op2(js_func2); |
2376 | 2392 |
2377 FieldGeneralizationChecker checker( | 2393 FieldGeneralizationChecker checker( |
2378 kPropCount - 1, Representation::HeapObject(), function_type); | 2394 kPropCount - 1, Representation::HeapObject(), function_type); |
2379 TestTransitionTo(transition_op1, transition_op2, checker); | 2395 TestTransitionTo(transition_op1, transition_op2, checker); |
2380 } | 2396 } |
2381 | 2397 |
2382 | 2398 |
2383 TEST(TransitionDataConstantToDataField) { | 2399 TEST(TransitionDataConstantToDataField) { |
2384 CcTest::InitializeVM(); | 2400 CcTest::InitializeVM(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 Isolate* isolate = CcTest::i_isolate(); | 2433 Isolate* isolate = CcTest::i_isolate(); |
2418 | 2434 |
2419 Zone zone(isolate->allocator(), ZONE_NAME); | 2435 Zone zone(isolate->allocator(), ZONE_NAME); |
2420 | 2436 |
2421 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); | 2437 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); |
2422 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); | 2438 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); |
2423 } | 2439 } |
2424 | 2440 |
2425 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2441 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
2426 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2442 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
OLD | NEW |