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

Side by Side Diff: src/runtime.cc

Issue 606062: Fix construction of simple objects with setters on prototype... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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/objects.cc ('k') | test/mjsunit/setter-on-constructor-prototype.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 4831 matching lines...) Expand 10 before | Expand all | Expand 10 after
4842 4842
4843 PretenureFlag pretenure = (context->global_context() == *context) 4843 PretenureFlag pretenure = (context->global_context() == *context)
4844 ? TENURED // Allocate global closures in old space. 4844 ? TENURED // Allocate global closures in old space.
4845 : NOT_TENURED; // Allocate local closures in new space. 4845 : NOT_TENURED; // Allocate local closures in new space.
4846 Handle<JSFunction> result = 4846 Handle<JSFunction> result =
4847 Factory::NewFunctionFromBoilerplate(boilerplate, context, pretenure); 4847 Factory::NewFunctionFromBoilerplate(boilerplate, context, pretenure);
4848 return *result; 4848 return *result;
4849 } 4849 }
4850 4850
4851 4851
4852 static Code* ComputeConstructStub(Handle<SharedFunctionInfo> shared) { 4852 static Code* ComputeConstructStub(Handle<JSFunction> function) {
4853 if (FLAG_inline_new 4853 if (FLAG_inline_new
4854 && shared->has_only_simple_this_property_assignments()) { 4854 && function->shared()->has_only_simple_this_property_assignments()
4855 && (!function->has_instance_prototype()
4856 || !JSObject::cast(function->instance_prototype())->HasSetter())) {
4855 ConstructStubCompiler compiler; 4857 ConstructStubCompiler compiler;
4856 Object* code = compiler.CompileConstructStub(*shared); 4858 Object* code = compiler.CompileConstructStub(function->shared());
4857 if (code->IsFailure()) { 4859 if (code->IsFailure()) {
4858 return Builtins::builtin(Builtins::JSConstructStubGeneric); 4860 return Builtins::builtin(Builtins::JSConstructStubGeneric);
4859 } 4861 }
4860 return Code::cast(code); 4862 return Code::cast(code);
4861 } 4863 }
4862 4864
4863 return shared->construct_stub(); 4865 return function->shared()->construct_stub();
4864 } 4866 }
4865 4867
4866 4868
4867 static Object* Runtime_NewObject(Arguments args) { 4869 static Object* Runtime_NewObject(Arguments args) {
4868 HandleScope scope; 4870 HandleScope scope;
4869 ASSERT(args.length() == 1); 4871 ASSERT(args.length() == 1);
4870 4872
4871 Handle<Object> constructor = args.at<Object>(0); 4873 Handle<Object> constructor = args.at<Object>(0);
4872 4874
4873 // If the constructor isn't a proper function we throw a type error. 4875 // If the constructor isn't a proper function we throw a type error.
(...skipping 29 matching lines...) Expand all
4903 } 4905 }
4904 } 4906 }
4905 4907
4906 // The function should be compiled for the optimization hints to be available. 4908 // The function should be compiled for the optimization hints to be available.
4907 Handle<SharedFunctionInfo> shared(function->shared()); 4909 Handle<SharedFunctionInfo> shared(function->shared());
4908 EnsureCompiled(shared, CLEAR_EXCEPTION); 4910 EnsureCompiled(shared, CLEAR_EXCEPTION);
4909 4911
4910 bool first_allocation = !function->has_initial_map(); 4912 bool first_allocation = !function->has_initial_map();
4911 Handle<JSObject> result = Factory::NewJSObject(function); 4913 Handle<JSObject> result = Factory::NewJSObject(function);
4912 if (first_allocation) { 4914 if (first_allocation) {
4913 Handle<Map> map = Handle<Map>(function->initial_map());
4914 Handle<Code> stub = Handle<Code>( 4915 Handle<Code> stub = Handle<Code>(
4915 ComputeConstructStub(Handle<SharedFunctionInfo>(function->shared()))); 4916 ComputeConstructStub(Handle<JSFunction>(function)));
4916 function->shared()->set_construct_stub(*stub); 4917 shared->set_construct_stub(*stub);
4917 } 4918 }
4918 4919
4919 Counters::constructed_objects.Increment(); 4920 Counters::constructed_objects.Increment();
4920 Counters::constructed_objects_runtime.Increment(); 4921 Counters::constructed_objects_runtime.Increment();
4921 4922
4922 return *result; 4923 return *result;
4923 } 4924 }
4924 4925
4925 4926
4926 static Object* Runtime_LazyCompile(Arguments args) { 4927 static Object* Runtime_LazyCompile(Arguments args) {
(...skipping 3311 matching lines...) Expand 10 before | Expand all | Expand 10 after
8238 } else { 8239 } else {
8239 // Handle last resort GC and make sure to allow future allocations 8240 // Handle last resort GC and make sure to allow future allocations
8240 // to grow the heap without causing GCs (if possible). 8241 // to grow the heap without causing GCs (if possible).
8241 Counters::gc_last_resort_from_js.Increment(); 8242 Counters::gc_last_resort_from_js.Increment();
8242 Heap::CollectAllGarbage(false); 8243 Heap::CollectAllGarbage(false);
8243 } 8244 }
8244 } 8245 }
8245 8246
8246 8247
8247 } } // namespace v8::internal 8248 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/setter-on-constructor-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698