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/bootstrapper.cc

Issue 6696018: Revert "Strict mode ThrowTypeError functions for" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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/arm/lithium-codegen-arm.cc ('k') | src/builtins.h » ('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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // triggered during environment creation there may be weak handle 200 // triggered during environment creation there may be weak handle
201 // processing callbacks which may create new environments. 201 // processing callbacks which may create new environments.
202 Genesis* previous_; 202 Genesis* previous_;
203 203
204 Handle<Context> global_context() { return global_context_; } 204 Handle<Context> global_context() { return global_context_; }
205 205
206 // Creates some basic objects. Used for creating a context from scratch. 206 // Creates some basic objects. Used for creating a context from scratch.
207 void CreateRoots(); 207 void CreateRoots();
208 // Creates the empty function. Used for creating a context from scratch. 208 // Creates the empty function. Used for creating a context from scratch.
209 Handle<JSFunction> CreateEmptyFunction(); 209 Handle<JSFunction> CreateEmptyFunction();
210 void CreateThrowTypeErrorCallbacks(
211 Handle<FixedArray> callbacks,
212 Builtins::Name builtin);
213 void CreateThrowTypeError(Handle<JSFunction> empty);
214 // Creates the global objects using the global and the template passed in 210 // Creates the global objects using the global and the template passed in
215 // through the API. We call this regardless of whether we are building a 211 // through the API. We call this regardless of whether we are building a
216 // context from scratch or using a deserialized one from the partial snapshot 212 // context from scratch or using a deserialized one from the partial snapshot
217 // but in the latter case we don't use the objects it produces directly, as 213 // but in the latter case we don't use the objects it produces directly, as
218 // we have to used the deserialized ones that are linked together with the 214 // we have to used the deserialized ones that are linked together with the
219 // rest of the context snapshot. 215 // rest of the context snapshot.
220 Handle<JSGlobalProxy> CreateNewGlobals( 216 Handle<JSGlobalProxy> CreateNewGlobals(
221 v8::Handle<v8::ObjectTemplate> global_template, 217 v8::Handle<v8::ObjectTemplate> global_template,
222 Handle<Object> global_object, 218 Handle<Object> global_object,
223 Handle<GlobalObject>* global_proxy_out); 219 Handle<GlobalObject>* global_proxy_out);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to); 256 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
261 257
262 enum PrototypePropertyMode { 258 enum PrototypePropertyMode {
263 DONT_ADD_PROTOTYPE, 259 DONT_ADD_PROTOTYPE,
264 ADD_READONLY_PROTOTYPE, 260 ADD_READONLY_PROTOTYPE,
265 ADD_WRITEABLE_PROTOTYPE 261 ADD_WRITEABLE_PROTOTYPE
266 }; 262 };
267 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( 263 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
268 PrototypePropertyMode prototypeMode); 264 PrototypePropertyMode prototypeMode);
269 void MakeFunctionInstancePrototypeWritable(); 265 void MakeFunctionInstancePrototypeWritable();
270 Handle<DescriptorArray> ComputeStrictFunctionDescriptor(
271 PrototypePropertyMode propertyMode,
272 Handle<FixedArray> arguments,
273 Handle<FixedArray> caller);
274 266
275 static bool CompileBuiltin(int index); 267 static bool CompileBuiltin(int index);
276 static bool CompileNative(Vector<const char> name, Handle<String> source); 268 static bool CompileNative(Vector<const char> name, Handle<String> source);
277 static bool CompileScriptCached(Vector<const char> name, 269 static bool CompileScriptCached(Vector<const char> name,
278 Handle<String> source, 270 Handle<String> source,
279 SourceCodeCache* cache, 271 SourceCodeCache* cache,
280 v8::Extension* extension, 272 v8::Extension* extension,
281 Handle<Context> top_context, 273 Handle<Context> top_context,
282 bool use_runtime_context); 274 bool use_runtime_context);
283 275
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 Handle<Map> empty_fm = Factory::CopyMapDropDescriptors( 492 Handle<Map> empty_fm = Factory::CopyMapDropDescriptors(
501 function_without_prototype_map); 493 function_without_prototype_map);
502 empty_fm->set_instance_descriptors( 494 empty_fm->set_instance_descriptors(
503 *function_without_prototype_map_descriptors); 495 *function_without_prototype_map_descriptors);
504 empty_fm->set_prototype(global_context()->object_function()->prototype()); 496 empty_fm->set_prototype(global_context()->object_function()->prototype());
505 empty_function->set_map(*empty_fm); 497 empty_function->set_map(*empty_fm);
506 return empty_function; 498 return empty_function;
507 } 499 }
508 500
509 501
510 Handle<DescriptorArray> Genesis::ComputeStrictFunctionDescriptor(
511 PrototypePropertyMode prototypeMode,
512 Handle<FixedArray> arguments,
513 Handle<FixedArray> caller) {
514 Handle<DescriptorArray> descriptors =
515 Factory::NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5);
516 PropertyAttributes attributes = static_cast<PropertyAttributes>(
517 DONT_ENUM | DONT_DELETE | READ_ONLY);
518
519 { // length
520 Handle<Proxy> proxy = Factory::NewProxy(&Accessors::FunctionLength);
521 CallbacksDescriptor d(*Factory::length_symbol(), *proxy, attributes);
522 descriptors->Set(0, &d);
523 }
524 { // name
525 Handle<Proxy> proxy = Factory::NewProxy(&Accessors::FunctionName);
526 CallbacksDescriptor d(*Factory::name_symbol(), *proxy, attributes);
527 descriptors->Set(1, &d);
528 }
529 { // arguments
530 CallbacksDescriptor d(*Factory::arguments_symbol(), *arguments, attributes);
531 descriptors->Set(2, &d);
532 }
533 { // caller
534 CallbacksDescriptor d(*Factory::caller_symbol(), *caller, attributes);
535 descriptors->Set(3, &d);
536 }
537
538 // prototype
539 if (prototypeMode != DONT_ADD_PROTOTYPE) {
540 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
541 attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
542 }
543 CallbacksDescriptor d(
544 *Factory::prototype_symbol(),
545 *Factory::NewProxy(&Accessors::FunctionPrototype),
546 attributes);
547 descriptors->Set(4, &d);
548 }
549
550 descriptors->Sort();
551 return descriptors;
552 }
553
554
555 void Genesis::CreateThrowTypeErrorCallbacks(
556 Handle<FixedArray> callbacks,
557 Builtins::Name builtin) {
558 // Create the ThrowTypeError function.
559 Handle<String> name = Factory::LookupAsciiSymbol("ThrowTypeError");
560 Handle<JSFunction> pill = Factory::NewFunctionWithoutPrototypeStrict(name);
561 Handle<Code> code = Handle<Code>(Builtins::builtin(builtin));
562 pill->set_map(global_context()->function_map_strict());
563 pill->set_code(*code);
564 pill->shared()->set_code(*code);
565 pill->shared()->DontAdaptArguments();
566
567 // Install the poison pills into the calbacks array.
568 callbacks->set(0, *pill);
569 callbacks->set(1, *pill);
570
571 PreventExtensions(pill);
572 }
573
574
575 // ECMAScript 5th Edition, 13.2.3
576 void Genesis::CreateThrowTypeError(Handle<JSFunction> empty) {
577 // Create the pill callbacks arrays. The get/set callacks are installed
578 // after the maps get created below.
579 Handle<FixedArray> arguments = Factory::NewFixedArray(2, TENURED);
580 Handle<FixedArray> caller = Factory::NewFixedArray(2, TENURED);
581
582 { // Allocate map for the strict mode function instances.
583 Handle<Map> map = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
584 global_context()->set_function_instance_map_strict(*map);
585 Handle<DescriptorArray> descriptors = ComputeStrictFunctionDescriptor(
586 ADD_WRITEABLE_PROTOTYPE, arguments, caller);
587 map->set_instance_descriptors(*descriptors);
588 map->set_function_with_prototype(true);
589 map->set_prototype(*empty);
590 }
591
592 { // Allocate map for the prototype-less strict mode instances.
593 Handle<Map> map = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
594 global_context()->set_function_without_prototype_map_strict(*map);
595 Handle<DescriptorArray> descriptors = ComputeStrictFunctionDescriptor(
596 DONT_ADD_PROTOTYPE, arguments, caller);
597 map->set_instance_descriptors(*descriptors);
598 map->set_function_with_prototype(false);
599 map->set_prototype(*empty);
600 }
601
602 { // Allocate map for the strict mode functions.
603 Handle<Map> map = Factory::NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
604 global_context()->set_function_map_strict(*map);
605 Handle<DescriptorArray> descriptors = ComputeStrictFunctionDescriptor(
606 ADD_READONLY_PROTOTYPE, arguments, caller);
607 map->set_instance_descriptors(*descriptors);
608 map->set_function_with_prototype(true);
609 map->set_prototype(*empty);
610 }
611
612 CreateThrowTypeErrorCallbacks(arguments, Builtins::StrictFunctionArguments);
613 CreateThrowTypeErrorCallbacks(caller, Builtins::StrictFunctionCaller);
614 }
615
616
617 static void AddToWeakGlobalContextList(Context* context) { 502 static void AddToWeakGlobalContextList(Context* context) {
618 ASSERT(context->IsGlobalContext()); 503 ASSERT(context->IsGlobalContext());
619 #ifdef DEBUG 504 #ifdef DEBUG
620 { // NOLINT 505 { // NOLINT
621 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); 506 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
622 // Check that context is not in the list yet. 507 // Check that context is not in the list yet.
623 for (Object* current = Heap::global_contexts_list(); 508 for (Object* current = Heap::global_contexts_list();
624 !current->IsUndefined(); 509 !current->IsUndefined();
625 current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) { 510 current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) {
626 ASSERT(current != context); 511 ASSERT(current != context);
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 &inner_global); 1851 &inner_global);
1967 1852
1968 HookUpGlobalProxy(inner_global, global_proxy); 1853 HookUpGlobalProxy(inner_global, global_proxy);
1969 HookUpInnerGlobal(inner_global); 1854 HookUpInnerGlobal(inner_global);
1970 1855
1971 if (!ConfigureGlobalObjects(global_template)) return; 1856 if (!ConfigureGlobalObjects(global_template)) return;
1972 } else { 1857 } else {
1973 // We get here if there was no context snapshot. 1858 // We get here if there was no context snapshot.
1974 CreateRoots(); 1859 CreateRoots();
1975 Handle<JSFunction> empty_function = CreateEmptyFunction(); 1860 Handle<JSFunction> empty_function = CreateEmptyFunction();
1976 CreateThrowTypeError(empty_function);
1977 Handle<GlobalObject> inner_global; 1861 Handle<GlobalObject> inner_global;
1978 Handle<JSGlobalProxy> global_proxy = 1862 Handle<JSGlobalProxy> global_proxy =
1979 CreateNewGlobals(global_template, global_object, &inner_global); 1863 CreateNewGlobals(global_template, global_object, &inner_global);
1980 HookUpGlobalProxy(inner_global, global_proxy); 1864 HookUpGlobalProxy(inner_global, global_proxy);
1981 InitializeGlobal(inner_global, empty_function); 1865 InitializeGlobal(inner_global, empty_function);
1982 InstallJSFunctionResultCaches(); 1866 InstallJSFunctionResultCaches();
1983 InitializeNormalizedMapCaches(); 1867 InitializeNormalizedMapCaches();
1984 if (!InstallNatives()) return; 1868 if (!InstallNatives()) return;
1985 1869
1986 MakeFunctionInstancePrototypeWritable(); 1870 MakeFunctionInstancePrototypeWritable();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 } 1917 }
2034 1918
2035 1919
2036 // Restore statics that are thread local. 1920 // Restore statics that are thread local.
2037 char* BootstrapperActive::RestoreState(char* from) { 1921 char* BootstrapperActive::RestoreState(char* from) {
2038 nesting_ = *reinterpret_cast<int*>(from); 1922 nesting_ = *reinterpret_cast<int*>(from);
2039 return from + sizeof(nesting_); 1923 return from + sizeof(nesting_);
2040 } 1924 }
2041 1925
2042 } } // namespace v8::internal 1926 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698