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

Side by Side Diff: src/runtime.cc

Issue 6223: Make sure that the name accessor on functions return the expected... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 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 | Annotate | Revision Log
« no previous file with comments | « src/regexp-delay.js ('k') | src/runtime.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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 130
131 static Object* Runtime_CreateObjectLiteralBoilerplate(Arguments args) { 131 static Object* Runtime_CreateObjectLiteralBoilerplate(Arguments args) {
132 HandleScope scope; 132 HandleScope scope;
133 ASSERT(args.length() == 3); 133 ASSERT(args.length() == 3);
134 // Copy the arguments. 134 // Copy the arguments.
135 Handle<FixedArray> literals = args.at<FixedArray>(0); 135 Handle<FixedArray> literals = args.at<FixedArray>(0);
136 int literals_index = Smi::cast(args[1])->value(); 136 int literals_index = Smi::cast(args[1])->value();
137 Handle<FixedArray> constant_properties = args.at<FixedArray>(2); 137 Handle<FixedArray> constant_properties = args.at<FixedArray>(2);
138
139 // Get the global context from the literals array. This is the
140 // context in which the function was created and we use the object
141 // function from this context to create the object literal. We do
142 // not use the object function from the current global context
143 // because this might be the object function from another context
144 // which we should not have access to.
138 Handle<Context> context = 145 Handle<Context> context =
139 Handle<Context>(JSFunction::GlobalContextFromLiterals(*literals)); 146 Handle<Context>(JSFunction::GlobalContextFromLiterals(*literals));
140 147
141 bool is_result_from_cache; 148 bool is_result_from_cache;
142 Handle<Map> map = ComputeObjectLiteralMap(context, 149 Handle<Map> map = ComputeObjectLiteralMap(context,
143 constant_properties, 150 constant_properties,
144 is_result_from_cache); 151 is_result_from_cache);
145 152
146 // Get the object function from the literals array. This is the
147 // object function from the context in which the function was
148 // created. We do not use the object function from the current
149 // global context because this might be the object function from
150 // another context which we should not have access to.
151 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map); 153 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map);
152 { // Add the constant propeties to the boilerplate. 154 { // Add the constant propeties to the boilerplate.
153 int length = constant_properties->length(); 155 int length = constant_properties->length();
154 OptimizedObjectForAddingMultipleProperties opt(boilerplate, 156 OptimizedObjectForAddingMultipleProperties opt(boilerplate,
155 !is_result_from_cache); 157 !is_result_from_cache);
156 for (int index = 0; index < length; index +=2) { 158 for (int index = 0; index < length; index +=2) {
157 Handle<Object> key(constant_properties->get(index+0)); 159 Handle<Object> key(constant_properties->get(index+0));
158 Handle<Object> value(constant_properties->get(index+1)); 160 Handle<Object> value(constant_properties->get(index+1));
159 uint32_t element_index = 0; 161 uint32_t element_index = 0;
160 if (key->IsSymbol()) { 162 if (key->IsSymbol()) {
(...skipping 21 matching lines...) Expand all
182 literals->set(literals_index, *boilerplate); 184 literals->set(literals_index, *boilerplate);
183 185
184 return *boilerplate; 186 return *boilerplate;
185 } 187 }
186 188
187 189
188 static Object* Runtime_CreateArrayLiteral(Arguments args) { 190 static Object* Runtime_CreateArrayLiteral(Arguments args) {
189 // Takes a FixedArray of elements containing the literal elements of 191 // Takes a FixedArray of elements containing the literal elements of
190 // the array literal and produces JSArray with those elements. 192 // the array literal and produces JSArray with those elements.
191 // Additionally takes the literals array of the surrounding function 193 // Additionally takes the literals array of the surrounding function
192 // which contains the Array function to use for creating the array 194 // which contains the context from which to get the Array function
193 // literal. 195 // to use for creating the array literal.
194 ASSERT(args.length() == 2); 196 ASSERT(args.length() == 2);
195 CONVERT_CHECKED(FixedArray, elements, args[0]); 197 CONVERT_CHECKED(FixedArray, elements, args[0]);
196 CONVERT_CHECKED(FixedArray, literals, args[1]); 198 CONVERT_CHECKED(FixedArray, literals, args[1]);
197 JSFunction* constructor = 199 JSFunction* constructor =
198 JSFunction::GlobalContextFromLiterals(literals)->array_function(); 200 JSFunction::GlobalContextFromLiterals(literals)->array_function();
199 // Create the JSArray. 201 // Create the JSArray.
200 Object* object = Heap::AllocateJSObject(constructor); 202 Object* object = Heap::AllocateJSObject(constructor);
201 if (object->IsFailure()) return object; 203 if (object->IsFailure()) return object;
202 204
203 // Copy the elements. 205 // Copy the elements.
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 722
721 723
722 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) { 724 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
723 HandleScope scope; 725 HandleScope scope;
724 ASSERT(args.length() == 4); 726 ASSERT(args.length() == 4);
725 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 727 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
726 int index = Smi::cast(args[1])->value(); 728 int index = Smi::cast(args[1])->value();
727 Handle<String> pattern = args.at<String>(2); 729 Handle<String> pattern = args.at<String>(2);
728 Handle<String> flags = args.at<String>(3); 730 Handle<String> flags = args.at<String>(3);
729 731
730 // Get the RegExp function from the literals array. This is the 732 // Get the RegExp function from the context in the literals array.
731 // RegExp function from the context in which the function was 733 // This is the RegExp function from the context in which the
732 // created. We do not use the RegExp function from the current 734 // function was created. We do not use the RegExp function from the
733 // global context because this might be the RegExp function from 735 // current global context because this might be the RegExp function
734 // another context which we should not have access to. 736 // from another context which we should not have access to.
735 Handle<JSFunction> constructor = 737 Handle<JSFunction> constructor =
736 Handle<JSFunction>( 738 Handle<JSFunction>(
737 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function()); 739 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function());
738 // Compute the regular expression literal. 740 // Compute the regular expression literal.
739 bool has_pending_exception; 741 bool has_pending_exception;
740 Handle<Object> regexp = 742 Handle<Object> regexp =
741 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags, 743 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags,
742 &has_pending_exception); 744 &has_pending_exception);
743 if (has_pending_exception) { 745 if (has_pending_exception) {
744 ASSERT(Top::has_pending_exception()); 746 ASSERT(Top::has_pending_exception());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); 850 Handle<JSFunction> fun = Handle<JSFunction>::cast(code);
849 SetExpectedNofProperties(target, fun->shared()->expected_nof_properties()); 851 SetExpectedNofProperties(target, fun->shared()->expected_nof_properties());
850 if (!fun->is_compiled() && !CompileLazy(fun, KEEP_EXCEPTION)) { 852 if (!fun->is_compiled() && !CompileLazy(fun, KEEP_EXCEPTION)) {
851 return Failure::Exception(); 853 return Failure::Exception();
852 } 854 }
853 // Set the code, formal parameter count, and the length of the target 855 // Set the code, formal parameter count, and the length of the target
854 // function. 856 // function.
855 target->set_code(fun->code()); 857 target->set_code(fun->code());
856 target->shared()->set_length(fun->shared()->length()); 858 target->shared()->set_length(fun->shared()->length());
857 target->shared()->set_formal_parameter_count( 859 target->shared()->set_formal_parameter_count(
858 fun->shared()->formal_parameter_count()); 860 fun->shared()->formal_parameter_count());
859 // Set the source code of the target function. 861 // Set the source code of the target function.
860 target->shared()->set_script(fun->shared()->script()); 862 target->shared()->set_script(fun->shared()->script());
861 target->shared()->set_start_position(fun->shared()->start_position()); 863 target->shared()->set_start_position(fun->shared()->start_position());
862 target->shared()->set_end_position(fun->shared()->end_position()); 864 target->shared()->set_end_position(fun->shared()->end_position());
863 context = Handle<Context>(fun->context()); 865 context = Handle<Context>(fun->context());
864 866
865 // Make sure we get a fresh copy of the literal vector to avoid 867 // Make sure we get a fresh copy of the literal vector to avoid
866 // cross context contamination. 868 // cross context contamination.
867 int number_of_literals = fun->NumberOfLiterals(); 869 int number_of_literals = fun->NumberOfLiterals();
868 Handle<FixedArray> literals = 870 Handle<FixedArray> literals =
(...skipping 4153 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 5024
5023 void Runtime::PerformGC(Object* result) { 5025 void Runtime::PerformGC(Object* result) {
5024 Failure* failure = Failure::cast(result); 5026 Failure* failure = Failure::cast(result);
5025 // Try to do a garbage collection; ignore it if it fails. The C 5027 // Try to do a garbage collection; ignore it if it fails. The C
5026 // entry stub will throw an out-of-memory exception in that case. 5028 // entry stub will throw an out-of-memory exception in that case.
5027 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); 5029 Heap::CollectGarbage(failure->requested(), failure->allocation_space());
5028 } 5030 }
5029 5031
5030 5032
5031 } } // namespace v8::internal 5033 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-delay.js ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698