Chromium Code Reviews| 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/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1502 // Should be a TypeError | 1502 // Should be a TypeError |
| 1503 CHECK(result->IsJSObject()); | 1503 CHECK(result->IsJSObject()); |
| 1504 | 1504 |
| 1505 Handle<Object> constructor = | 1505 Handle<Object> constructor = |
| 1506 Object::GetPropertyOrElement(result, | 1506 Object::GetPropertyOrElement(result, |
| 1507 isolate->factory()->constructor_string()) | 1507 isolate->factory()->constructor_string()) |
| 1508 .ToHandleChecked(); | 1508 .ToHandleChecked(); |
| 1509 CHECK(constructor->SameValue(*isolate->type_error_function())); | 1509 CHECK(constructor->SameValue(*isolate->type_error_function())); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 TEST(AllocateJSObjectFromMap) { | |
| 1513 Isolate* isolate(CcTest::InitIsolateOnce()); | |
| 1514 Factory* factory = isolate->factory(); | |
| 1515 | |
| 1516 const int kNumParams = 3; | |
| 1517 CodeStubAssemblerTester m(isolate, kNumParams); | |
| 1518 | |
| 1519 Handle<Symbol> not_found_symbol = factory->NewSymbol(); | |
| 1520 Handle<Symbol> bailout_symbol = factory->NewSymbol(); | |
| 1521 { | |
| 1522 Node* map = m.Parameter(0); | |
| 1523 Node* properties = m.Parameter(1); | |
| 1524 Node* elements = m.Parameter(2); | |
| 1525 | |
| 1526 Node* result = m.AllocateJSObjectFromMap(map, properties, elements); | |
| 1527 | |
| 1528 m.Return(result); | |
| 1529 } | |
| 1530 | |
| 1531 Handle<Code> code = m.GenerateCode(); | |
| 1532 FunctionTester ft(code, kNumParams); | |
| 1533 | |
| 1534 Handle<Map> maps[] = { | |
| 1535 isolate->object_with_null_prototype_map(), | |
| 1536 handle(isolate->object_function()->initial_map(), isolate), | |
| 1537 handle(isolate->array_function()->initial_map(), isolate), | |
| 1538 }; | |
| 1539 | |
| 1540 #define VERIFY(result, map_handle, properties_handle, elements_handle) \ | |
|
Igor Sheludko
2016/10/18 12:33:22
s/_handle/_value/
| |
| 1541 CHECK_EQ(result->map(), map_handle); \ | |
| 1542 CHECK_EQ(result->properties(), properties_handle); \ | |
| 1543 CHECK_EQ(result->elements(), elements_handle); | |
| 1544 | |
| 1545 { | |
| 1546 Handle<Object> empty_fixed_array = factory->empty_fixed_array(); | |
| 1547 for (int i = 0; i < arraysize(maps); i++) { | |
| 1548 Handle<Map> map = maps[i]; | |
| 1549 Handle<JSObject> result = Handle<JSObject>::cast( | |
| 1550 ft.Call(map, empty_fixed_array, empty_fixed_array).ToHandleChecked()); | |
| 1551 VERIFY(result, *map, *empty_fixed_array, *empty_fixed_array); | |
| 1552 #ifdef VERIFY_HEAP | |
| 1553 isolate->heap()->Verify(); | |
| 1554 #endif | |
| 1555 } | |
| 1556 } | |
| 1557 | |
| 1558 { | |
| 1559 // TODO(cbruni): handle in-object properties | |
| 1560 Handle<JSObject> object = Handle<JSObject>::cast( | |
| 1561 v8::Utils::OpenHandle(*CompileRun("var object = {a:1,b:2, 1:1, 2:2}; " | |
| 1562 "object"))); | |
| 1563 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, | |
| 1564 "Normalize"); | |
| 1565 Handle<JSObject> result = Handle<JSObject>::cast( | |
| 1566 ft.Call(handle(object->map()), handle(object->properties()), | |
| 1567 handle(object->elements())) | |
| 1568 .ToHandleChecked()); | |
| 1569 VERIFY(result, object->map(), object->properties(), object->elements()); | |
| 1570 #ifdef VERIFY_HEAP | |
| 1571 isolate->heap()->Verify(); | |
| 1572 #endif | |
| 1573 } | |
| 1574 } | |
| 1575 | |
| 1512 } // namespace internal | 1576 } // namespace internal |
| 1513 } // namespace v8 | 1577 } // namespace v8 |
| OLD | NEW |