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

Side by Side Diff: src/bootstrapper.cc

Issue 9152001: Introduce a new AccessorPair type for handling JavaScript accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments Created 8 years, 11 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 | « include/v8.h ('k') | src/factory.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); 258 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
259 259
260 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( 260 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
261 PrototypePropertyMode prototypeMode); 261 PrototypePropertyMode prototypeMode);
262 void MakeFunctionInstancePrototypeWritable(); 262 void MakeFunctionInstancePrototypeWritable();
263 263
264 Handle<Map> CreateStrictModeFunctionMap( 264 Handle<Map> CreateStrictModeFunctionMap(
265 PrototypePropertyMode prototype_mode, 265 PrototypePropertyMode prototype_mode,
266 Handle<JSFunction> empty_function, 266 Handle<JSFunction> empty_function,
267 Handle<FixedArray> arguments_callbacks, 267 Handle<AccessorPair> arguments_callbacks,
268 Handle<FixedArray> caller_callbacks); 268 Handle<AccessorPair> caller_callbacks);
269 269
270 Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor( 270 Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor(
271 PrototypePropertyMode propertyMode, 271 PrototypePropertyMode propertyMode,
272 Handle<FixedArray> arguments, 272 Handle<AccessorPair> arguments,
273 Handle<FixedArray> caller); 273 Handle<AccessorPair> caller);
274 274
275 static bool CompileBuiltin(Isolate* isolate, int index); 275 static bool CompileBuiltin(Isolate* isolate, int index);
276 static bool CompileExperimentalBuiltin(Isolate* isolate, int index); 276 static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
277 static bool CompileNative(Vector<const char> name, Handle<String> source); 277 static bool CompileNative(Vector<const char> name, Handle<String> source);
278 static bool CompileScriptCached(Vector<const char> name, 278 static bool CompileScriptCached(Vector<const char> name,
279 Handle<String> source, 279 Handle<String> source,
280 SourceCodeCache* cache, 280 SourceCodeCache* cache,
281 v8::Extension* extension, 281 v8::Extension* extension,
282 Handle<Context> top_context, 282 Handle<Context> top_context,
283 bool use_runtime_context); 283 bool use_runtime_context);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 empty_fm->set_instance_descriptors( 533 empty_fm->set_instance_descriptors(
534 function_without_prototype_map->instance_descriptors()); 534 function_without_prototype_map->instance_descriptors());
535 empty_fm->set_prototype(global_context()->object_function()->prototype()); 535 empty_fm->set_prototype(global_context()->object_function()->prototype());
536 empty_function->set_map(*empty_fm); 536 empty_function->set_map(*empty_fm);
537 return empty_function; 537 return empty_function;
538 } 538 }
539 539
540 540
541 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( 541 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
542 PrototypePropertyMode prototypeMode, 542 PrototypePropertyMode prototypeMode,
543 Handle<FixedArray> arguments, 543 Handle<AccessorPair> arguments,
544 Handle<FixedArray> caller) { 544 Handle<AccessorPair> caller) {
545 Handle<DescriptorArray> descriptors = 545 Handle<DescriptorArray> descriptors =
546 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE 546 factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE
547 ? 4 547 ? 4
548 : 5); 548 : 5);
549 PropertyAttributes attributes = static_cast<PropertyAttributes>( 549 PropertyAttributes attributes = static_cast<PropertyAttributes>(
550 DONT_ENUM | DONT_DELETE); 550 DONT_ENUM | DONT_DELETE);
551 551
552 DescriptorArray::WhitenessWitness witness(*descriptors); 552 DescriptorArray::WhitenessWitness witness(*descriptors);
553 553
554 { // length 554 { // length
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 604
605 JSObject::PreventExtensions(throw_type_error_function); 605 JSObject::PreventExtensions(throw_type_error_function);
606 } 606 }
607 return throw_type_error_function; 607 return throw_type_error_function;
608 } 608 }
609 609
610 610
611 Handle<Map> Genesis::CreateStrictModeFunctionMap( 611 Handle<Map> Genesis::CreateStrictModeFunctionMap(
612 PrototypePropertyMode prototype_mode, 612 PrototypePropertyMode prototype_mode,
613 Handle<JSFunction> empty_function, 613 Handle<JSFunction> empty_function,
614 Handle<FixedArray> arguments_callbacks, 614 Handle<AccessorPair> arguments_callbacks,
615 Handle<FixedArray> caller_callbacks) { 615 Handle<AccessorPair> caller_callbacks) {
616 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 616 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
617 Handle<DescriptorArray> descriptors = 617 Handle<DescriptorArray> descriptors =
618 ComputeStrictFunctionInstanceDescriptor(prototype_mode, 618 ComputeStrictFunctionInstanceDescriptor(prototype_mode,
619 arguments_callbacks, 619 arguments_callbacks,
620 caller_callbacks); 620 caller_callbacks);
621 map->set_instance_descriptors(*descriptors); 621 map->set_instance_descriptors(*descriptors);
622 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); 622 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
623 map->set_prototype(*empty_function); 623 map->set_prototype(*empty_function);
624 return map; 624 return map;
625 } 625 }
626 626
627 627
628 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { 628 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
629 // Create the callbacks arrays for ThrowTypeError functions. 629 // Create the callbacks arrays for ThrowTypeError functions.
630 // The get/set callacks are filled in after the maps are created below. 630 // The get/set callacks are filled in after the maps are created below.
631 Factory* factory = empty->GetIsolate()->factory(); 631 Factory* factory = empty->GetIsolate()->factory();
632 Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED); 632 Handle<AccessorPair> arguments(factory->NewAccessorPair());
633 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); 633 Handle<AccessorPair> caller(factory->NewAccessorPair());
634 634
635 // Allocate map for the strict mode function instances. 635 // Allocate map for the strict mode function instances.
636 Handle<Map> strict_mode_function_instance_map = 636 Handle<Map> strict_mode_function_instance_map =
637 CreateStrictModeFunctionMap( 637 CreateStrictModeFunctionMap(
638 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); 638 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
639 global_context()->set_strict_mode_function_instance_map( 639 global_context()->set_strict_mode_function_instance_map(
640 *strict_mode_function_instance_map); 640 *strict_mode_function_instance_map);
641 641
642 // Allocate map for the prototype-less strict mode instances. 642 // Allocate map for the prototype-less strict mode instances.
643 Handle<Map> strict_mode_function_without_prototype_map = 643 Handle<Map> strict_mode_function_without_prototype_map =
(...skipping 14 matching lines...) Expand all
658 // The final map for the strict mode functions. Writeable prototype. 658 // The final map for the strict mode functions. Writeable prototype.
659 // This map is installed in MakeFunctionInstancePrototypeWritable. 659 // This map is installed in MakeFunctionInstancePrototypeWritable.
660 strict_mode_function_instance_map_writable_prototype_ = 660 strict_mode_function_instance_map_writable_prototype_ =
661 CreateStrictModeFunctionMap( 661 CreateStrictModeFunctionMap(
662 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); 662 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
663 663
664 // Create the ThrowTypeError function instance. 664 // Create the ThrowTypeError function instance.
665 Handle<JSFunction> throw_function = 665 Handle<JSFunction> throw_function =
666 GetThrowTypeErrorFunction(); 666 GetThrowTypeErrorFunction();
667 667
668 // Complete the callback fixed arrays. 668 // Complete the callbacks.
669 arguments->set(0, *throw_function); 669 arguments->set_getter(*throw_function);
670 arguments->set(1, *throw_function); 670 arguments->set_setter(*throw_function);
671 caller->set(0, *throw_function); 671 caller->set_getter(*throw_function);
672 caller->set(1, *throw_function); 672 caller->set_setter(*throw_function);
673 } 673 }
674 674
675 675
676 static void AddToWeakGlobalContextList(Context* context) { 676 static void AddToWeakGlobalContextList(Context* context) {
677 ASSERT(context->IsGlobalContext()); 677 ASSERT(context->IsGlobalContext());
678 Heap* heap = context->GetIsolate()->heap(); 678 Heap* heap = context->GetIsolate()->heap();
679 #ifdef DEBUG 679 #ifdef DEBUG
680 { // NOLINT 680 { // NOLINT
681 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); 681 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
682 // Check that context is not in the list yet. 682 // Check that context is not in the list yet.
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 result->set_elements(*elements); 1135 result->set_elements(*elements);
1136 ASSERT(result->HasNonStrictArgumentsElements()); 1136 ASSERT(result->HasNonStrictArgumentsElements());
1137 global_context()->set_aliased_arguments_boilerplate(*result); 1137 global_context()->set_aliased_arguments_boilerplate(*result);
1138 } 1138 }
1139 1139
1140 { // --- strict mode arguments boilerplate 1140 { // --- strict mode arguments boilerplate
1141 const PropertyAttributes attributes = 1141 const PropertyAttributes attributes =
1142 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1142 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1143 1143
1144 // Create the ThrowTypeError functions. 1144 // Create the ThrowTypeError functions.
1145 Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED); 1145 Handle<AccessorPair> callee = factory->NewAccessorPair();
1146 Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); 1146 Handle<AccessorPair> caller = factory->NewAccessorPair();
1147 1147
1148 Handle<JSFunction> throw_function = 1148 Handle<JSFunction> throw_function =
1149 GetThrowTypeErrorFunction(); 1149 GetThrowTypeErrorFunction();
1150 1150
1151 // Install the ThrowTypeError functions. 1151 // Install the ThrowTypeError functions.
1152 callee->set(0, *throw_function); 1152 callee->set_getter(*throw_function);
1153 callee->set(1, *throw_function); 1153 callee->set_setter(*throw_function);
1154 caller->set(0, *throw_function); 1154 caller->set_getter(*throw_function);
1155 caller->set(1, *throw_function); 1155 caller->set_setter(*throw_function);
1156 1156
1157 // Create the descriptor array for the arguments object. 1157 // Create the descriptor array for the arguments object.
1158 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); 1158 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
1159 DescriptorArray::WhitenessWitness witness(*descriptors); 1159 DescriptorArray::WhitenessWitness witness(*descriptors);
1160 { // length 1160 { // length
1161 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); 1161 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
1162 descriptors->Set(0, &d, witness); 1162 descriptors->Set(0, &d, witness);
1163 } 1163 }
1164 { // callee 1164 { // callee
1165 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes); 1165 CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes);
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 return from + sizeof(NestingCounterType); 2374 return from + sizeof(NestingCounterType);
2375 } 2375 }
2376 2376
2377 2377
2378 // Called when the top-level V8 mutex is destroyed. 2378 // Called when the top-level V8 mutex is destroyed.
2379 void Bootstrapper::FreeThreadResources() { 2379 void Bootstrapper::FreeThreadResources() {
2380 ASSERT(!IsActive()); 2380 ASSERT(!IsActive());
2381 } 2381 }
2382 2382
2383 } } // namespace v8::internal 2383 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698