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

Side by Side Diff: src/bootstrapper.cc

Issue 6698015: Implement strict mode arguments caller/callee. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Kevin's feedback. 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/full-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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 JSObject::kHeaderSize, 987 JSObject::kHeaderSize,
988 prototype, 988 prototype,
989 code, 989 code,
990 false); 990 false);
991 ASSERT(!function->has_initial_map()); 991 ASSERT(!function->has_initial_map());
992 function->shared()->set_instance_class_name(*symbol); 992 function->shared()->set_instance_class_name(*symbol);
993 function->shared()->set_expected_nof_properties(2); 993 function->shared()->set_expected_nof_properties(2);
994 Handle<JSObject> result = Factory::NewJSObject(function); 994 Handle<JSObject> result = Factory::NewJSObject(function);
995 995
996 global_context()->set_arguments_boilerplate(*result); 996 global_context()->set_arguments_boilerplate(*result);
997 // Note: callee must be added as the first property and 997 // Note: length must be added as the first property and
998 // length must be added as the second property. 998 // callee must be added as the second property.
999 SetLocalPropertyNoThrow(result, Factory::length_symbol(),
1000 Factory::undefined_value(),
1001 DONT_ENUM);
999 SetLocalPropertyNoThrow(result, Factory::callee_symbol(), 1002 SetLocalPropertyNoThrow(result, Factory::callee_symbol(),
1000 Factory::undefined_value(), 1003 Factory::undefined_value(),
1001 DONT_ENUM); 1004 DONT_ENUM);
1002 SetLocalPropertyNoThrow(result, Factory::length_symbol(),
1003 Factory::undefined_value(),
1004 DONT_ENUM);
1005 1005
1006 #ifdef DEBUG 1006 #ifdef DEBUG
1007 LookupResult lookup; 1007 LookupResult lookup;
1008 result->LocalLookup(Heap::callee_symbol(), &lookup); 1008 result->LocalLookup(Heap::callee_symbol(), &lookup);
1009 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); 1009 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1010 ASSERT(lookup.GetFieldIndex() == Heap::arguments_callee_index); 1010 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex);
1011 1011
1012 result->LocalLookup(Heap::length_symbol(), &lookup); 1012 result->LocalLookup(Heap::length_symbol(), &lookup);
1013 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); 1013 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1014 ASSERT(lookup.GetFieldIndex() == Heap::arguments_length_index); 1014 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
1015 1015
1016 ASSERT(result->map()->inobject_properties() > Heap::arguments_callee_index); 1016 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
1017 ASSERT(result->map()->inobject_properties() > Heap::arguments_length_index); 1017 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1018 1018
1019 // Check the state of the object. 1019 // Check the state of the object.
1020 ASSERT(result->HasFastProperties()); 1020 ASSERT(result->HasFastProperties());
1021 ASSERT(result->HasFastElements());
1022 #endif
1023 }
1024
1025 { // --- strict mode arguments boilerplate
1026 const PropertyAttributes attributes =
1027 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1028
1029 // 1. Create the poison pills.
1030 Handle<FixedArray> callee = Factory::NewFixedArray(2, TENURED);
1031 Handle<FixedArray> caller = Factory::NewFixedArray(2, TENURED);
1032 CreateThrowTypeErrorCallbacks(callee, Builtins::StrictArgumentsCallee);
1033 CreateThrowTypeErrorCallbacks(caller, Builtins::StrictArgumentsCaller);
1034
1035 // 2. Create the descriptor array for the arguments object.
1036 Handle<DescriptorArray> descriptors = Factory::NewDescriptorArray(3);
1037 { // length
1038 FieldDescriptor d(*Factory::length_symbol(), 0, DONT_ENUM);
1039 descriptors->Set(0, &d);
1040 }
1041 { // callee
1042 CallbacksDescriptor d(*Factory::callee_symbol(), *callee, attributes);
1043 descriptors->Set(1, &d);
1044 }
1045 { // caller
1046 CallbacksDescriptor d(*Factory::caller_symbol(), *caller, attributes);
1047 descriptors->Set(2, &d);
1048 }
1049 descriptors->Sort();
1050
1051 // 3. Create the map. Allocate one in-object field for length.
1052 Handle<Map> map = Factory::NewMap(JS_OBJECT_TYPE,
1053 Heap::kArgumentsObjectSizeStrict);
1054 map->set_instance_descriptors(*descriptors);
1055 map->set_function_with_prototype(true);
1056 map->set_prototype(global_context()->object_function()->prototype());
1057 map->set_pre_allocated_property_fields(1);
1058 map->set_inobject_properties(1);
1059
1060 // 4. Copy constructor from the non-strict arguments boilerplate.
1061 map->set_constructor(
1062 global_context()->arguments_boilerplate()->map()->constructor());
1063
1064 // 5. Allocate the arguments boilerplate object.
1065 Handle<JSObject> result = Factory::NewJSObjectFromMap(map);
1066 global_context()->set_strict_mode_arguments_boilerplate(*result);
1067
1068 // 6. Add length property only for strict mode boilerplate.
1069 SetLocalPropertyNoThrow(result, Factory::length_symbol(),
1070 Factory::undefined_value(),
1071 DONT_ENUM);
1072
1073 #ifdef DEBUG
1074 LookupResult lookup;
1075 result->LocalLookup(Heap::length_symbol(), &lookup);
1076 ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1077 ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
1078
1079 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1080
1081 // Check the state of the object.
1082 ASSERT(result->HasFastProperties());
1021 ASSERT(result->HasFastElements()); 1083 ASSERT(result->HasFastElements());
1022 #endif 1084 #endif
1023 } 1085 }
1024 1086
1025 { // --- context extension 1087 { // --- context extension
1026 // Create a function for the context extension objects. 1088 // Create a function for the context extension objects.
1027 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 1089 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal));
1028 Handle<JSFunction> context_extension_fun = 1090 Handle<JSFunction> context_extension_fun =
1029 Factory::NewFunction(Factory::empty_symbol(), 1091 Factory::NewFunction(Factory::empty_symbol(),
1030 JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1092 JS_CONTEXT_EXTENSION_OBJECT_TYPE,
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 } 2095 }
2034 2096
2035 2097
2036 // Restore statics that are thread local. 2098 // Restore statics that are thread local.
2037 char* BootstrapperActive::RestoreState(char* from) { 2099 char* BootstrapperActive::RestoreState(char* from) {
2038 nesting_ = *reinterpret_cast<int*>(from); 2100 nesting_ = *reinterpret_cast<int*>(from);
2039 return from + sizeof(nesting_); 2101 return from + sizeof(nesting_);
2040 } 2102 }
2041 2103
2042 } } // namespace v8::internal 2104 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698