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

Side by Side Diff: src/bootstrapper.cc

Issue 352813002: Wrap InitializeProperty around SetOwnPropertyIgnoreAttributes and switch over uses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | « no previous file | src/factory.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ? factory->NewFunction(internalized_name, call_code, prototype, 372 ? factory->NewFunction(internalized_name, call_code, prototype,
373 type, instance_size) 373 type, instance_size)
374 : factory->NewFunctionWithoutPrototype(internalized_name, call_code); 374 : factory->NewFunctionWithoutPrototype(internalized_name, call_code);
375 PropertyAttributes attributes; 375 PropertyAttributes attributes;
376 if (target->IsJSBuiltinsObject()) { 376 if (target->IsJSBuiltinsObject()) {
377 attributes = 377 attributes =
378 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 378 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
379 } else { 379 } else {
380 attributes = DONT_ENUM; 380 attributes = DONT_ENUM;
381 } 381 }
382 JSObject::SetOwnPropertyIgnoreAttributes( 382 JSObject::AddProperty(target, internalized_name, function, attributes);
383 target, internalized_name, function, attributes).Check();
384 if (target->IsJSGlobalObject()) { 383 if (target->IsJSGlobalObject()) {
385 function->shared()->set_instance_class_name(*internalized_name); 384 function->shared()->set_instance_class_name(*internalized_name);
386 } 385 }
387 function->shared()->set_native(true); 386 function->shared()->set_native(true);
388 return function; 387 return function;
389 } 388 }
390 389
391 390
392 void Genesis::SetFunctionInstanceDescriptor( 391 void Genesis::SetFunctionInstanceDescriptor(
393 Handle<Map> map, FunctionMode function_mode) { 392 Handle<Map> map, FunctionMode function_mode) {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // its the inner global. This makes the security check between two 881 // its the inner global. This makes the security check between two
883 // different contexts fail by default even in case of global 882 // different contexts fail by default even in case of global
884 // object reinitialization. 883 // object reinitialization.
885 native_context()->set_security_token(*inner_global); 884 native_context()->set_security_token(*inner_global);
886 885
887 Isolate* isolate = inner_global->GetIsolate(); 886 Isolate* isolate = inner_global->GetIsolate();
888 Factory* factory = isolate->factory(); 887 Factory* factory = isolate->factory();
889 Heap* heap = isolate->heap(); 888 Heap* heap = isolate->heap();
890 889
891 Handle<String> object_name = factory->Object_string(); 890 Handle<String> object_name = factory->Object_string();
892 JSObject::SetOwnPropertyIgnoreAttributes( 891 JSObject::AddProperty(
893 inner_global, object_name, 892 inner_global, object_name, isolate->object_function(), DONT_ENUM);
894 isolate->object_function(), DONT_ENUM).Check();
895 893
896 Handle<JSObject> global(native_context()->global_object()); 894 Handle<JSObject> global(native_context()->global_object());
897 895
898 // Install global Function object 896 // Install global Function object
899 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 897 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
900 empty_function, Builtins::kIllegal); 898 empty_function, Builtins::kIllegal);
901 899
902 { // --- A r r a y --- 900 { // --- A r r a y ---
903 Handle<JSFunction> array_function = 901 Handle<JSFunction> array_function =
904 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 902 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 } 1081 }
1084 1082
1085 { // -- J S O N 1083 { // -- J S O N
1086 Handle<String> name = factory->InternalizeUtf8String("JSON"); 1084 Handle<String> name = factory->InternalizeUtf8String("JSON");
1087 Handle<JSFunction> cons = factory->NewFunction(name); 1085 Handle<JSFunction> cons = factory->NewFunction(name);
1088 JSFunction::SetInstancePrototype(cons, 1086 JSFunction::SetInstancePrototype(cons,
1089 Handle<Object>(native_context()->initial_object_prototype(), isolate)); 1087 Handle<Object>(native_context()->initial_object_prototype(), isolate));
1090 cons->SetInstanceClassName(*name); 1088 cons->SetInstanceClassName(*name);
1091 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); 1089 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
1092 ASSERT(json_object->IsJSObject()); 1090 ASSERT(json_object->IsJSObject());
1093 JSObject::SetOwnPropertyIgnoreAttributes( 1091 JSObject::AddProperty(global, name, json_object, DONT_ENUM);
1094 global, name, json_object, DONT_ENUM).Check();
1095 native_context()->set_json_object(*json_object); 1092 native_context()->set_json_object(*json_object);
1096 } 1093 }
1097 1094
1098 { // -- A r r a y B u f f e r 1095 { // -- A r r a y B u f f e r
1099 Handle<JSFunction> array_buffer_fun = 1096 Handle<JSFunction> array_buffer_fun =
1100 InstallFunction( 1097 InstallFunction(
1101 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, 1098 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
1102 JSArrayBuffer::kSizeWithInternalFields, 1099 JSArrayBuffer::kSizeWithInternalFields,
1103 isolate->initial_object_prototype(), 1100 isolate->initial_object_prototype(),
1104 Builtins::kIllegal); 1101 Builtins::kIllegal);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 ASSERT(!function->has_initial_map()); 1146 ASSERT(!function->has_initial_map());
1150 function->shared()->set_instance_class_name(*arguments_string); 1147 function->shared()->set_instance_class_name(*arguments_string);
1151 function->shared()->set_expected_nof_properties(2); 1148 function->shared()->set_expected_nof_properties(2);
1152 function->set_prototype_or_initial_map( 1149 function->set_prototype_or_initial_map(
1153 native_context()->object_function()->prototype()); 1150 native_context()->object_function()->prototype());
1154 Handle<JSObject> result = factory->NewJSObject(function); 1151 Handle<JSObject> result = factory->NewJSObject(function);
1155 1152
1156 native_context()->set_sloppy_arguments_boilerplate(*result); 1153 native_context()->set_sloppy_arguments_boilerplate(*result);
1157 // Note: length must be added as the first property and 1154 // Note: length must be added as the first property and
1158 // callee must be added as the second property. 1155 // callee must be added as the second property.
1159 JSObject::SetOwnPropertyIgnoreAttributes( 1156 JSObject::AddProperty(
1160 result, factory->length_string(), 1157 result, factory->length_string(),
1161 factory->undefined_value(), DONT_ENUM, 1158 factory->undefined_value(), DONT_ENUM,
1162 Object::FORCE_TAGGED, FORCE_FIELD).Check(); 1159 Object::FORCE_TAGGED, FORCE_FIELD);
1163 JSObject::SetOwnPropertyIgnoreAttributes( 1160 JSObject::AddProperty(
1164 result, factory->callee_string(), 1161 result, factory->callee_string(),
1165 factory->undefined_value(), DONT_ENUM, 1162 factory->undefined_value(), DONT_ENUM,
1166 Object::FORCE_TAGGED, FORCE_FIELD).Check(); 1163 Object::FORCE_TAGGED, FORCE_FIELD);
1167 1164
1168 #ifdef DEBUG 1165 #ifdef DEBUG
1169 LookupResult lookup(isolate); 1166 LookupResult lookup(isolate);
1170 result->LookupOwn(factory->callee_string(), &lookup); 1167 result->LookupOwn(factory->callee_string(), &lookup);
1171 ASSERT(lookup.IsField()); 1168 ASSERT(lookup.IsField());
1172 ASSERT(lookup.GetFieldIndex().property_index() == 1169 ASSERT(lookup.GetFieldIndex().property_index() ==
1173 Heap::kArgumentsCalleeIndex); 1170 Heap::kArgumentsCalleeIndex);
1174 1171
1175 result->LookupOwn(factory->length_string(), &lookup); 1172 result->LookupOwn(factory->length_string(), &lookup);
1176 ASSERT(lookup.IsField()); 1173 ASSERT(lookup.IsField());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 map->set_inobject_properties(1); 1252 map->set_inobject_properties(1);
1256 1253
1257 // Copy constructor from the sloppy arguments boilerplate. 1254 // Copy constructor from the sloppy arguments boilerplate.
1258 map->set_constructor( 1255 map->set_constructor(
1259 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); 1256 native_context()->sloppy_arguments_boilerplate()->map()->constructor());
1260 1257
1261 // Allocate the arguments boilerplate object. 1258 // Allocate the arguments boilerplate object.
1262 Handle<JSObject> result = factory->NewJSObjectFromMap(map); 1259 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1263 native_context()->set_strict_arguments_boilerplate(*result); 1260 native_context()->set_strict_arguments_boilerplate(*result);
1264 1261
1265 // Add length property only for strict mode boilerplate.
1266 JSObject::SetOwnPropertyIgnoreAttributes(
1267 result, factory->length_string(),
1268 factory->undefined_value(), DONT_ENUM).Check();
1269
1270 #ifdef DEBUG 1262 #ifdef DEBUG
1271 LookupResult lookup(isolate); 1263 LookupResult lookup(isolate);
1272 result->LookupOwn(factory->length_string(), &lookup); 1264 result->LookupOwn(factory->length_string(), &lookup);
1273 ASSERT(lookup.IsField()); 1265 ASSERT(lookup.IsField());
1274 ASSERT(lookup.GetFieldIndex().property_index() == 1266 ASSERT(lookup.GetFieldIndex().property_index() ==
1275 Heap::kArgumentsLengthIndex); 1267 Heap::kArgumentsLengthIndex);
1276 1268
1269 Handle<Object> length_value = Object::GetProperty(
1270 result, factory->length_string()).ToHandleChecked();
1271 ASSERT_EQ(heap->undefined_value(), *length_value);
1272
1277 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); 1273 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1278 1274
1279 // Check the state of the object. 1275 // Check the state of the object.
1280 ASSERT(result->HasFastProperties()); 1276 ASSERT(result->HasFastProperties());
1281 ASSERT(result->HasFastObjectElements()); 1277 ASSERT(result->HasFastObjectElements());
1282 #endif 1278 #endif
1283 } 1279 }
1284 1280
1285 { // --- context extension 1281 { // --- context extension
1286 // Create a function for the context extension objects. 1282 // Create a function for the context extension objects.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 1725
1730 // Set up the 'global' properties of the builtins object. The 1726 // Set up the 'global' properties of the builtins object. The
1731 // 'global' property that refers to the global object is the only 1727 // 'global' property that refers to the global object is the only
1732 // way to get from code running in the builtins context to the 1728 // way to get from code running in the builtins context to the
1733 // global object. 1729 // global object.
1734 static const PropertyAttributes attributes = 1730 static const PropertyAttributes attributes =
1735 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1731 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1736 Handle<String> global_string = 1732 Handle<String> global_string =
1737 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); 1733 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global"));
1738 Handle<Object> global_obj(native_context()->global_object(), isolate()); 1734 Handle<Object> global_obj(native_context()->global_object(), isolate());
1739 JSObject::SetOwnPropertyIgnoreAttributes( 1735 JSObject::AddProperty(builtins, global_string, global_obj, attributes);
1740 builtins, global_string, global_obj, attributes).Check();
1741 Handle<String> builtins_string = 1736 Handle<String> builtins_string =
1742 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); 1737 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
1743 JSObject::SetOwnPropertyIgnoreAttributes( 1738 JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
1744 builtins, builtins_string, builtins, attributes).Check();
1745 1739
1746 // Set up the reference from the global object to the builtins object. 1740 // Set up the reference from the global object to the builtins object.
1747 JSGlobalObject::cast(native_context()->global_object())-> 1741 JSGlobalObject::cast(native_context()->global_object())->
1748 set_builtins(*builtins); 1742 set_builtins(*builtins);
1749 1743
1750 // Create a bridge function that has context in the native context. 1744 // Create a bridge function that has context in the native context.
1751 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); 1745 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string());
1752 ASSERT(bridge->context() == *isolate()->native_context()); 1746 ASSERT(bridge->context() == *isolate()->native_context());
1753 1747
1754 // Allocate the builtins context. 1748 // Allocate the builtins context.
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { 2441 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) {
2448 PropertyDetails details = descs->GetDetails(i); 2442 PropertyDetails details = descs->GetDetails(i);
2449 switch (details.type()) { 2443 switch (details.type()) {
2450 case FIELD: { 2444 case FIELD: {
2451 HandleScope inner(isolate()); 2445 HandleScope inner(isolate());
2452 Handle<Name> key = Handle<Name>(descs->GetKey(i)); 2446 Handle<Name> key = Handle<Name>(descs->GetKey(i));
2453 FieldIndex index = FieldIndex::ForDescriptor(from->map(), i); 2447 FieldIndex index = FieldIndex::ForDescriptor(from->map(), i);
2454 ASSERT(!descs->GetDetails(i).representation().IsDouble()); 2448 ASSERT(!descs->GetDetails(i).representation().IsDouble());
2455 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), 2449 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index),
2456 isolate()); 2450 isolate());
2457 JSObject::SetOwnPropertyIgnoreAttributes( 2451 JSObject::AddProperty(to, key, value, details.attributes());
2458 to, key, value, details.attributes()).Check();
2459 break; 2452 break;
2460 } 2453 }
2461 case CONSTANT: { 2454 case CONSTANT: {
2462 HandleScope inner(isolate()); 2455 HandleScope inner(isolate());
2463 Handle<Name> key = Handle<Name>(descs->GetKey(i)); 2456 Handle<Name> key = Handle<Name>(descs->GetKey(i));
2464 Handle<Object> constant(descs->GetConstant(i), isolate()); 2457 Handle<Object> constant(descs->GetConstant(i), isolate());
2465 JSObject::SetOwnPropertyIgnoreAttributes( 2458 JSObject::AddProperty(to, key, constant, details.attributes());
2466 to, key, constant, details.attributes()).Check();
2467 break; 2459 break;
2468 } 2460 }
2469 case CALLBACKS: { 2461 case CALLBACKS: {
2470 LookupResult result(isolate()); 2462 LookupResult result(isolate());
2471 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); 2463 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate());
2472 to->LookupOwn(key, &result); 2464 to->LookupOwn(key, &result);
2473 // If the property is already there we skip it 2465 // If the property is already there we skip it
2474 if (result.IsFound()) continue; 2466 if (result.IsFound()) continue;
2475 HandleScope inner(isolate()); 2467 HandleScope inner(isolate());
2476 ASSERT(!to->HasFastProperties()); 2468 ASSERT(!to->HasFastProperties());
(...skipping 29 matching lines...) Expand all
2506 if (result.IsFound()) continue; 2498 if (result.IsFound()) continue;
2507 // Set the property. 2499 // Set the property.
2508 Handle<Object> value = Handle<Object>(properties->ValueAt(i), 2500 Handle<Object> value = Handle<Object>(properties->ValueAt(i),
2509 isolate()); 2501 isolate());
2510 ASSERT(!value->IsCell()); 2502 ASSERT(!value->IsCell());
2511 if (value->IsPropertyCell()) { 2503 if (value->IsPropertyCell()) {
2512 value = Handle<Object>(PropertyCell::cast(*value)->value(), 2504 value = Handle<Object>(PropertyCell::cast(*value)->value(),
2513 isolate()); 2505 isolate());
2514 } 2506 }
2515 PropertyDetails details = properties->DetailsAt(i); 2507 PropertyDetails details = properties->DetailsAt(i);
2516 JSObject::SetOwnPropertyIgnoreAttributes( 2508 JSObject::AddProperty(to, key, value, details.attributes());
2517 to, key, value, details.attributes()).Check();
2518 } 2509 }
2519 } 2510 }
2520 } 2511 }
2521 } 2512 }
2522 2513
2523 2514
2524 void Genesis::TransferIndexedProperties(Handle<JSObject> from, 2515 void Genesis::TransferIndexedProperties(Handle<JSObject> from,
2525 Handle<JSObject> to) { 2516 Handle<JSObject> to) {
2526 // Cloning the elements array is sufficient. 2517 // Cloning the elements array is sufficient.
2527 Handle<FixedArray> from_elements = 2518 Handle<FixedArray> from_elements =
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 return from + sizeof(NestingCounterType); 2732 return from + sizeof(NestingCounterType);
2742 } 2733 }
2743 2734
2744 2735
2745 // Called when the top-level V8 mutex is destroyed. 2736 // Called when the top-level V8 mutex is destroyed.
2746 void Bootstrapper::FreeThreadResources() { 2737 void Bootstrapper::FreeThreadResources() {
2747 ASSERT(!IsActive()); 2738 ASSERT(!IsActive());
2748 } 2739 }
2749 2740
2750 } } // namespace v8::internal 2741 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698