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

Side by Side Diff: src/runtime.cc

Issue 12422019: ES6 symbols: prevent reflection and proxy APIs from leaking symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Deal with Object.observe as well Created 7 years, 9 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 | Annotate | Revision Log
« 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 4727 matching lines...) Expand 10 before | Expand all | Expand 10 after
4738 proto = JSObject::cast(proto)->GetPrototype(); 4738 proto = JSObject::cast(proto)->GetPrototype();
4739 } 4739 }
4740 return count; 4740 return count;
4741 } 4741 }
4742 4742
4743 4743
4744 // Return the names of the local named properties. 4744 // Return the names of the local named properties.
4745 // args[0]: object 4745 // args[0]: object
4746 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { 4746 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
4747 HandleScope scope(isolate); 4747 HandleScope scope(isolate);
4748 ASSERT(args.length() == 1); 4748 ASSERT(args.length() == 2);
4749 if (!args[0]->IsJSObject()) { 4749 if (!args[0]->IsJSObject()) {
4750 return isolate->heap()->undefined_value(); 4750 return isolate->heap()->undefined_value();
4751 } 4751 }
4752 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 4752 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
4753 CONVERT_BOOLEAN_ARG_CHECKED(include_symbols, 1);
4754 PropertyAttributes filter = include_symbols ? NONE : SYMBOLIC;
4753 4755
4754 // Skip the global proxy as it has no properties and always delegates to the 4756 // Skip the global proxy as it has no properties and always delegates to the
4755 // real global object. 4757 // real global object.
4756 if (obj->IsJSGlobalProxy()) { 4758 if (obj->IsJSGlobalProxy()) {
4757 // Only collect names if access is permitted. 4759 // Only collect names if access is permitted.
4758 if (obj->IsAccessCheckNeeded() && 4760 if (obj->IsAccessCheckNeeded() &&
4759 !isolate->MayNamedAccess(*obj, 4761 !isolate->MayNamedAccess(*obj,
4760 isolate->heap()->undefined_value(), 4762 isolate->heap()->undefined_value(),
4761 v8::ACCESS_KEYS)) { 4763 v8::ACCESS_KEYS)) {
4762 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS); 4764 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
(...skipping 12 matching lines...) Expand all
4775 for (int i = 0; i < length; i++) { 4777 for (int i = 0; i < length; i++) {
4776 // Only collect names if access is permitted. 4778 // Only collect names if access is permitted.
4777 if (jsproto->IsAccessCheckNeeded() && 4779 if (jsproto->IsAccessCheckNeeded() &&
4778 !isolate->MayNamedAccess(*jsproto, 4780 !isolate->MayNamedAccess(*jsproto,
4779 isolate->heap()->undefined_value(), 4781 isolate->heap()->undefined_value(),
4780 v8::ACCESS_KEYS)) { 4782 v8::ACCESS_KEYS)) {
4781 isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS); 4783 isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
4782 return *isolate->factory()->NewJSArray(0); 4784 return *isolate->factory()->NewJSArray(0);
4783 } 4785 }
4784 int n; 4786 int n;
4785 n = jsproto->NumberOfLocalProperties(); 4787 n = jsproto->NumberOfLocalProperties(filter);
4786 local_property_count[i] = n; 4788 local_property_count[i] = n;
4787 total_property_count += n; 4789 total_property_count += n;
4788 if (i < length - 1) { 4790 if (i < length - 1) {
4789 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 4791 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
4790 } 4792 }
4791 } 4793 }
4792 4794
4793 // Allocate an array with storage for all the property names. 4795 // Allocate an array with storage for all the property names.
4794 Handle<FixedArray> names = 4796 Handle<FixedArray> names =
4795 isolate->factory()->NewFixedArray(total_property_count); 4797 isolate->factory()->NewFixedArray(total_property_count);
4796 4798
4797 // Get the property names. 4799 // Get the property names.
4798 jsproto = obj; 4800 jsproto = obj;
4799 int proto_with_hidden_properties = 0; 4801 int proto_with_hidden_properties = 0;
4800 int next_copy_index = 0; 4802 int next_copy_index = 0;
4801 for (int i = 0; i < length; i++) { 4803 for (int i = 0; i < length; i++) {
4802 jsproto->GetLocalPropertyNames(*names, next_copy_index); 4804 jsproto->GetLocalPropertyNames(*names, next_copy_index, filter);
4803 next_copy_index += local_property_count[i]; 4805 next_copy_index += local_property_count[i];
4804 if (jsproto->HasHiddenProperties()) { 4806 if (jsproto->HasHiddenProperties()) {
4805 proto_with_hidden_properties++; 4807 proto_with_hidden_properties++;
4806 } 4808 }
4807 if (i < length - 1) { 4809 if (i < length - 1) {
4808 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 4810 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
4809 } 4811 }
4810 } 4812 }
4811 4813
4812 // Filter out name of hidden propeties object. 4814 // Filter out name of hidden properties object.
4813 if (proto_with_hidden_properties > 0) { 4815 if (proto_with_hidden_properties > 0) {
4814 Handle<FixedArray> old_names = names; 4816 Handle<FixedArray> old_names = names;
4815 names = isolate->factory()->NewFixedArray( 4817 names = isolate->factory()->NewFixedArray(
4816 names->length() - proto_with_hidden_properties); 4818 names->length() - proto_with_hidden_properties);
4817 int dest_pos = 0; 4819 int dest_pos = 0;
4818 for (int i = 0; i < total_property_count; i++) { 4820 for (int i = 0; i < total_property_count; i++) {
4819 Object* name = old_names->get(i); 4821 Object* name = old_names->get(i);
4820 if (name == isolate->heap()->hidden_string()) { 4822 if (name == isolate->heap()->hidden_string()) {
4821 continue; 4823 continue;
4822 } 4824 }
(...skipping 8179 matching lines...) Expand 10 before | Expand all | Expand 10 after
13002 // Handle last resort GC and make sure to allow future allocations 13004 // Handle last resort GC and make sure to allow future allocations
13003 // to grow the heap without causing GCs (if possible). 13005 // to grow the heap without causing GCs (if possible).
13004 isolate->counters()->gc_last_resort_from_js()->Increment(); 13006 isolate->counters()->gc_last_resort_from_js()->Increment();
13005 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13007 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13006 "Runtime::PerformGC"); 13008 "Runtime::PerformGC");
13007 } 13009 }
13008 } 13010 }
13009 13011
13010 13012
13011 } } // namespace v8::internal 13013 } } // 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