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

Side by Side Diff: src/execution.cc

Issue 113634: Propagate information on whether a non function was called as constructor or not (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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/execution.h ('k') | src/ia32/builtins-ia32.cc » ('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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (object->IsHeapObject() && 181 if (object->IsHeapObject() &&
182 HeapObject::cast(*object)->map()->has_instance_call_handler()) { 182 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
183 return Handle<JSFunction>( 183 return Handle<JSFunction>(
184 Top::global_context()->call_as_function_delegate()); 184 Top::global_context()->call_as_function_delegate());
185 } 185 }
186 186
187 return Factory::undefined_value(); 187 return Factory::undefined_value();
188 } 188 }
189 189
190 190
191 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) {
192 ASSERT(!object->IsJSFunction());
193
194 // If you return a function from here, it will be called when an
195 // attempt is made to call the given object as a constructor.
196
197 // Objects created through the API can have an instance-call handler
198 // that should be used when calling the object as a function.
199 if (object->IsHeapObject() &&
200 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
201 return Handle<JSFunction>(
202 Top::global_context()->call_as_constructor_delegate());
203 }
204
205 return Factory::undefined_value();
206 }
207
208
191 // Static state for stack guards. 209 // Static state for stack guards.
192 StackGuard::ThreadLocal StackGuard::thread_local_; 210 StackGuard::ThreadLocal StackGuard::thread_local_;
193 211
194 212
195 StackGuard::StackGuard() { 213 StackGuard::StackGuard() {
196 // NOTE: Overall the StackGuard code assumes that the stack grows towards 214 // NOTE: Overall the StackGuard code assumes that the stack grows towards
197 // lower addresses. 215 // lower addresses.
198 ExecutionAccess access; 216 ExecutionAccess access;
199 if (thread_local_.nesting_++ == 0) { 217 if (thread_local_.nesting_++ == 0) {
200 // Initial StackGuard is being set. We will set the stack limits based on 218 // Initial StackGuard is being set. We will set the stack limits based on
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // All allocation spaces other than NEW_SPACE have the same effect. 658 // All allocation spaces other than NEW_SPACE have the same effect.
641 Heap::CollectAllGarbage(); 659 Heap::CollectAllGarbage();
642 return v8::Undefined(); 660 return v8::Undefined();
643 } 661 }
644 662
645 663
646 static GCExtension kGCExtension; 664 static GCExtension kGCExtension;
647 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); 665 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension);
648 666
649 } } // namespace v8::internal 667 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698