Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2385423005: [stubs] Implement fast TF Builtin for Object.create (Closed)
Patch Set: removing unused symbol Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/object-create.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
1520 Node* map = m.Parameter(0);
1521 Node* properties = m.Parameter(1);
1522 Node* elements = m.Parameter(2);
1523
1524 Node* result = m.AllocateJSObjectFromMap(map, properties, elements);
1525
1526 m.Return(result);
1527 }
1528
1529 Handle<Code> code = m.GenerateCode();
1530 FunctionTester ft(code, kNumParams);
1531
1532 Handle<Map> maps[] = {
1533 isolate->object_with_null_prototype_map(),
1534 handle(isolate->object_function()->initial_map(), isolate),
1535 handle(isolate->array_function()->initial_map(), isolate),
1536 };
1537
1538 #define VERIFY(result, map_value, properties_value, elements_value) \
1539 CHECK_EQ(result->map(), map_value); \
1540 CHECK_EQ(result->properties(), properties_value); \
1541 CHECK_EQ(result->elements(), elements_value);
1542
1543 {
1544 Handle<Object> empty_fixed_array = factory->empty_fixed_array();
1545 for (int i = 0; i < arraysize(maps); i++) {
1546 Handle<Map> map = maps[i];
1547 Handle<JSObject> result = Handle<JSObject>::cast(
1548 ft.Call(map, empty_fixed_array, empty_fixed_array).ToHandleChecked());
1549 VERIFY(result, *map, *empty_fixed_array, *empty_fixed_array);
1550 #ifdef VERIFY_HEAP
1551 isolate->heap()->Verify();
1552 #endif
1553 }
1554 }
1555
1556 {
1557 // TODO(cbruni): handle in-object properties
1558 Handle<JSObject> object = Handle<JSObject>::cast(
1559 v8::Utils::OpenHandle(*CompileRun("var object = {a:1,b:2, 1:1, 2:2}; "
1560 "object")));
1561 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0,
1562 "Normalize");
1563 Handle<JSObject> result = Handle<JSObject>::cast(
1564 ft.Call(handle(object->map()), handle(object->properties()),
1565 handle(object->elements()))
1566 .ToHandleChecked());
1567 VERIFY(result, object->map(), object->properties(), object->elements());
1568 #ifdef VERIFY_HEAP
1569 isolate->heap()->Verify();
1570 #endif
1571 }
1572 }
1573
1512 } // namespace internal 1574 } // namespace internal
1513 } // namespace v8 1575 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/object-create.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698