| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 Handle<Map> AddAccessorConstant(Handle<Map> map, | 370 Handle<Map> AddAccessorConstant(Handle<Map> map, |
| 371 PropertyAttributes attributes, | 371 PropertyAttributes attributes, |
| 372 Handle<AccessorPair> pair) { | 372 Handle<AccessorPair> pair) { |
| 373 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 373 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 374 int property_index = number_of_properties_++; | 374 int property_index = number_of_properties_++; |
| 375 SetAccessorConstant(property_index, attributes, pair); | 375 SetAccessorConstant(property_index, attributes, pair); |
| 376 | 376 |
| 377 Handle<String> name = MakeName("prop", property_index); | 377 Handle<String> name = MakeName("prop", property_index); |
| 378 | 378 |
| 379 AccessorConstantDescriptor new_desc(name, pair, attributes); | 379 Descriptor d = Descriptor::AccessorConstant(name, pair, attributes); |
| 380 return Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION); | 380 return Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION); |
| 381 } | 381 } |
| 382 | 382 |
| 383 Handle<Map> AddAccessorConstant(Handle<Map> map, | 383 Handle<Map> AddAccessorConstant(Handle<Map> map, |
| 384 PropertyAttributes attributes, | 384 PropertyAttributes attributes, |
| 385 Handle<Object> getter, | 385 Handle<Object> getter, |
| 386 Handle<Object> setter) { | 386 Handle<Object> setter) { |
| 387 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 387 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 388 int property_index = number_of_properties_++; | 388 int property_index = number_of_properties_++; |
| 389 SetAccessorConstant(property_index, attributes, getter, setter); | 389 SetAccessorConstant(property_index, attributes, getter, setter); |
| 390 | 390 |
| 391 Handle<String> name = MakeName("prop", property_index); | 391 Handle<String> name = MakeName("prop", property_index); |
| 392 | 392 |
| 393 CHECK(!getter->IsNull(isolate_) || !setter->IsNull(isolate_)); | 393 CHECK(!getter->IsNull(isolate_) || !setter->IsNull(isolate_)); |
| 394 Factory* factory = isolate_->factory(); | 394 Factory* factory = isolate_->factory(); |
| 395 | 395 |
| 396 if (!getter->IsNull(isolate_)) { | 396 if (!getter->IsNull(isolate_)) { |
| 397 Handle<AccessorPair> pair = factory->NewAccessorPair(); | 397 Handle<AccessorPair> pair = factory->NewAccessorPair(); |
| 398 pair->SetComponents(*getter, *factory->null_value()); | 398 pair->SetComponents(*getter, *factory->null_value()); |
| 399 AccessorConstantDescriptor new_desc(name, pair, attributes); | 399 Descriptor d = Descriptor::AccessorConstant(name, pair, attributes); |
| 400 map = Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION); | 400 map = Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION); |
| 401 } | 401 } |
| 402 if (!setter->IsNull(isolate_)) { | 402 if (!setter->IsNull(isolate_)) { |
| 403 Handle<AccessorPair> pair = factory->NewAccessorPair(); | 403 Handle<AccessorPair> pair = factory->NewAccessorPair(); |
| 404 pair->SetComponents(*getter, *setter); | 404 pair->SetComponents(*getter, *setter); |
| 405 AccessorConstantDescriptor new_desc(name, pair, attributes); | 405 Descriptor d = Descriptor::AccessorConstant(name, pair, attributes); |
| 406 map = Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION); | 406 map = Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION); |
| 407 } | 407 } |
| 408 return map; | 408 return map; |
| 409 } | 409 } |
| 410 | 410 |
| 411 Handle<Map> TransitionToAccessorConstant(Handle<Map> map, | 411 Handle<Map> TransitionToAccessorConstant(Handle<Map> map, |
| 412 PropertyAttributes attributes, | 412 PropertyAttributes attributes, |
| 413 Handle<AccessorPair> pair) { | 413 Handle<AccessorPair> pair) { |
| 414 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 414 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 415 int property_index = number_of_properties_++; | 415 int property_index = number_of_properties_++; |
| 416 SetAccessorConstant(property_index, attributes, pair); | 416 SetAccessorConstant(property_index, attributes, pair); |
| (...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 Isolate* isolate = CcTest::i_isolate(); | 2417 Isolate* isolate = CcTest::i_isolate(); |
| 2418 | 2418 |
| 2419 Zone zone(isolate->allocator(), ZONE_NAME); | 2419 Zone zone(isolate->allocator(), ZONE_NAME); |
| 2420 | 2420 |
| 2421 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); | 2421 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); |
| 2422 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); | 2422 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); |
| 2423 } | 2423 } |
| 2424 | 2424 |
| 2425 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2425 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
| 2426 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2426 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
| OLD | NEW |