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

Side by Side Diff: src/runtime.cc

Issue 3191026: Explicitly set expected number of properties for instances of builtin types. (Closed)
Patch Set: Created 10 years, 3 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.h ('k') | src/v8natives.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1694
1695 CONVERT_ARG_CHECKED(JSFunction, target, 0); 1695 CONVERT_ARG_CHECKED(JSFunction, target, 0);
1696 Handle<Object> code = args.at<Object>(1); 1696 Handle<Object> code = args.at<Object>(1);
1697 1697
1698 Handle<Context> context(target->context()); 1698 Handle<Context> context(target->context());
1699 1699
1700 if (!code->IsNull()) { 1700 if (!code->IsNull()) {
1701 RUNTIME_ASSERT(code->IsJSFunction()); 1701 RUNTIME_ASSERT(code->IsJSFunction());
1702 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); 1702 Handle<JSFunction> fun = Handle<JSFunction>::cast(code);
1703 Handle<SharedFunctionInfo> shared(fun->shared()); 1703 Handle<SharedFunctionInfo> shared(fun->shared());
1704 SetExpectedNofProperties(target, shared->expected_nof_properties());
1705 1704
1706 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) { 1705 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) {
1707 return Failure::Exception(); 1706 return Failure::Exception();
1708 } 1707 }
1709 // Set the code, scope info, formal parameter count, 1708 // Set the code, scope info, formal parameter count,
1710 // and the length of the target function. 1709 // and the length of the target function.
1711 target->shared()->set_code(shared->code()); 1710 target->shared()->set_code(shared->code());
1712 target->set_code(shared->code()); 1711 target->set_code(shared->code());
1713 target->shared()->set_scope_info(shared->scope_info()); 1712 target->shared()->set_scope_info(shared->scope_info());
1714 target->shared()->set_length(shared->length()); 1713 target->shared()->set_length(shared->length());
(...skipping 24 matching lines...) Expand all
1739 // It's okay to skip the write barrier here because the literals 1738 // It's okay to skip the write barrier here because the literals
1740 // are guaranteed to be in old space. 1739 // are guaranteed to be in old space.
1741 target->set_literals(*literals, SKIP_WRITE_BARRIER); 1740 target->set_literals(*literals, SKIP_WRITE_BARRIER);
1742 } 1741 }
1743 1742
1744 target->set_context(*context); 1743 target->set_context(*context);
1745 return *target; 1744 return *target;
1746 } 1745 }
1747 1746
1748 1747
1748 static Object* Runtime_SetExpectedNumberOfProperties(Arguments args) {
1749 HandleScope scope;
1750 ASSERT(args.length() == 2);
1751 CONVERT_ARG_CHECKED(JSFunction, function, 0);
1752 CONVERT_SMI_CHECKED(num, args[1]);
1753 RUNTIME_ASSERT(num >= 0);
1754 SetExpectedNofProperties(function, num);
1755 return Heap::undefined_value();
1756 }
1757
1758
1749 static Object* CharFromCode(Object* char_code) { 1759 static Object* CharFromCode(Object* char_code) {
1750 uint32_t code; 1760 uint32_t code;
1751 if (char_code->ToArrayIndex(&code)) { 1761 if (char_code->ToArrayIndex(&code)) {
1752 if (code <= 0xffff) { 1762 if (code <= 0xffff) {
1753 return Heap::LookupSingleCharacterStringFromCode(code); 1763 return Heap::LookupSingleCharacterStringFromCode(code);
1754 } 1764 }
1755 } 1765 }
1756 return Heap::empty_string(); 1766 return Heap::empty_string();
1757 } 1767 }
1758 1768
(...skipping 8949 matching lines...) Expand 10 before | Expand all | Expand 10 after
10708 } else { 10718 } else {
10709 // Handle last resort GC and make sure to allow future allocations 10719 // Handle last resort GC and make sure to allow future allocations
10710 // to grow the heap without causing GCs (if possible). 10720 // to grow the heap without causing GCs (if possible).
10711 Counters::gc_last_resort_from_js.Increment(); 10721 Counters::gc_last_resort_from_js.Increment();
10712 Heap::CollectAllGarbage(false); 10722 Heap::CollectAllGarbage(false);
10713 } 10723 }
10714 } 10724 }
10715 10725
10716 10726
10717 } } // namespace v8::internal 10727 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698