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

Side by Side Diff: src/builtins.cc

Issue 1553043002: [builtins] Migrate a bunch of Object builtins to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/builtins.h ('k') | src/contexts.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 Handle<Object> properties = args.atOrUndefined(isolate, 2); 1515 Handle<Object> properties = args.atOrUndefined(isolate, 2);
1516 if (!properties->IsUndefined()) { 1516 if (!properties->IsUndefined()) {
1517 RETURN_FAILURE_ON_EXCEPTION( 1517 RETURN_FAILURE_ON_EXCEPTION(
1518 isolate, JSReceiver::DefineProperties(isolate, object, properties)); 1518 isolate, JSReceiver::DefineProperties(isolate, object, properties));
1519 } 1519 }
1520 1520
1521 return *object; 1521 return *object;
1522 } 1522 }
1523 1523
1524 1524
1525 // ES6 section 19.1.2.5 Object.freeze ( O )
1526 BUILTIN(ObjectFreeze) {
1527 HandleScope scope(isolate);
1528 Handle<Object> object = args.atOrUndefined(isolate, 1);
1529 if (object->IsJSReceiver()) {
1530 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
1531 FROZEN, Object::THROW_ON_ERROR),
1532 isolate->heap()->exception());
1533 }
1534 return *object;
1535 }
1536
1537
1538 // ES6 section 19.1.2.11 Object.isExtensible ( O )
1539 BUILTIN(ObjectIsExtensible) {
1540 HandleScope scope(isolate);
1541 Handle<Object> object = args.atOrUndefined(isolate, 1);
1542 Maybe<bool> result =
1543 object->IsJSReceiver()
1544 ? JSReceiver::IsExtensible(Handle<JSReceiver>::cast(object))
1545 : Just(false);
1546 MAYBE_RETURN(result, isolate->heap()->exception());
1547 return isolate->heap()->ToBoolean(result.FromJust());
1548 }
1549
1550
1551 // ES6 section 19.1.2.12 Object.isFrozen ( O )
1552 BUILTIN(ObjectIsFrozen) {
1553 HandleScope scope(isolate);
1554 Handle<Object> object = args.atOrUndefined(isolate, 1);
1555 Maybe<bool> result = object->IsJSReceiver()
1556 ? JSReceiver::TestIntegrityLevel(
1557 Handle<JSReceiver>::cast(object), FROZEN)
1558 : Just(true);
1559 MAYBE_RETURN(result, isolate->heap()->exception());
1560 return isolate->heap()->ToBoolean(result.FromJust());
1561 }
1562
1563
1564 // ES6 section 19.1.2.13 Object.isSealed ( O )
1565 BUILTIN(ObjectIsSealed) {
1566 HandleScope scope(isolate);
1567 Handle<Object> object = args.atOrUndefined(isolate, 1);
1568 Maybe<bool> result = object->IsJSReceiver()
1569 ? JSReceiver::TestIntegrityLevel(
1570 Handle<JSReceiver>::cast(object), SEALED)
1571 : Just(true);
1572 MAYBE_RETURN(result, isolate->heap()->exception());
1573 return isolate->heap()->ToBoolean(result.FromJust());
1574 }
1575
1576
1577 // ES6 section 19.1.2.15 Object.preventExtensions ( O )
1578 BUILTIN(ObjectPreventExtensions) {
1579 HandleScope scope(isolate);
1580 Handle<Object> object = args.atOrUndefined(isolate, 1);
1581 if (object->IsJSReceiver()) {
1582 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object),
1583 Object::THROW_ON_ERROR),
1584 isolate->heap()->exception());
1585 }
1586 return *object;
1587 }
1588
1589
1590 // ES6 section 19.1.2.17 Object.seal ( O )
1591 BUILTIN(ObjectSeal) {
1592 HandleScope scope(isolate);
1593 Handle<Object> object = args.atOrUndefined(isolate, 1);
1594 if (object->IsJSReceiver()) {
1595 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
1596 SEALED, Object::THROW_ON_ERROR),
1597 isolate->heap()->exception());
1598 }
1599 return *object;
1600 }
1601
1602
1525 namespace { 1603 namespace {
1526 1604
1527 bool CodeGenerationFromStringsAllowed(Isolate* isolate, 1605 bool CodeGenerationFromStringsAllowed(Isolate* isolate,
1528 Handle<Context> context) { 1606 Handle<Context> context) {
1529 DCHECK(context->allow_code_gen_from_strings()->IsFalse()); 1607 DCHECK(context->allow_code_gen_from_strings()->IsFalse());
1530 // Check with callback if set. 1608 // Check with callback if set.
1531 AllowCodeGenerationFromStringsCallback callback = 1609 AllowCodeGenerationFromStringsCallback callback =
1532 isolate->allow_code_gen_callback(); 1610 isolate->allow_code_gen_callback();
1533 if (callback == NULL) { 1611 if (callback == NULL) {
1534 // No callback set and code generation disallowed. 1612 // No callback set and code generation disallowed.
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 2915 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
2838 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 2916 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
2839 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 2917 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
2840 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 2918 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
2841 #undef DEFINE_BUILTIN_ACCESSOR_C 2919 #undef DEFINE_BUILTIN_ACCESSOR_C
2842 #undef DEFINE_BUILTIN_ACCESSOR_A 2920 #undef DEFINE_BUILTIN_ACCESSOR_A
2843 2921
2844 2922
2845 } // namespace internal 2923 } // namespace internal
2846 } // namespace v8 2924 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698