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

Unified Diff: src/bootstrapper.cc

Issue 234783002: Handlify Map::CopyDropDescriptors(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more refactoring. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 4cfebadd57bf27daceb15f1990d171781f75a5e9..f6d9979e9f1f15514314f9d67a296804371b5195 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -383,8 +383,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
void Genesis::SetFunctionInstanceDescriptor(
Handle<Map> map, PrototypePropertyMode prototypeMode) {
int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
- Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
- DescriptorArray::WhitenessWitness witness(*descriptors);
+ Map::EnsureDescriptorSlack(map, size);
Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
@@ -396,23 +395,22 @@ void Genesis::SetFunctionInstanceDescriptor(
}
PropertyAttributes attribs = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE | READ_ONLY);
- map->set_instance_descriptors(*descriptors);
{ // Add length.
CallbacksDescriptor d(factory()->length_string(), length, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add name.
CallbacksDescriptor d(factory()->name_string(), name, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add arguments.
CallbacksDescriptor d(factory()->arguments_string(), args, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add caller.
CallbacksDescriptor d(factory()->caller_string(), caller, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
if (prototypeMode != DONT_ADD_PROTOTYPE) {
// Add prototype.
@@ -420,7 +418,7 @@ void Genesis::SetFunctionInstanceDescriptor(
attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
}
CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
}
@@ -522,8 +520,7 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
void Genesis::SetStrictFunctionInstanceDescriptor(
Handle<Map> map, PrototypePropertyMode prototypeMode) {
int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
- Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
- DescriptorArray::WhitenessWitness witness(*descriptors);
+ Map::EnsureDescriptorSlack(map, size);
Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
@@ -537,31 +534,30 @@ void Genesis::SetStrictFunctionInstanceDescriptor(
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
PropertyAttributes ro_attribs =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
- map->set_instance_descriptors(*descriptors);
{ // Add length.
CallbacksDescriptor d(factory()->length_string(), length, ro_attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add name.
CallbacksDescriptor d(factory()->name_string(), name, ro_attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add arguments.
CallbacksDescriptor d(factory()->arguments_string(), arguments,
rw_attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // Add caller.
CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
if (prototypeMode != DONT_ADD_PROTOTYPE) {
// Add prototype.
PropertyAttributes attribs =
prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs;
CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
}
@@ -861,19 +857,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// This assert protects an optimization in
// HGraphBuilder::JSArrayBuilder::EmitMapCode()
ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind());
-
- Handle<DescriptorArray> array_descriptors(
- factory->NewDescriptorArray(0, 1));
- DescriptorArray::WhitenessWitness witness(*array_descriptors);
+ Map::EnsureDescriptorSlack(initial_map, 1);
Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
PropertyAttributes attribs = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE);
- initial_map->set_instance_descriptors(*array_descriptors);
{ // Add length.
CallbacksDescriptor d(factory->length_string(), array_length, attribs);
- array_function->initial_map()->AppendDescriptor(&d, witness);
+ array_function->initial_map()->AppendDescriptor(&d);
}
// array_function is used internally. JS code creating array object should
@@ -916,19 +908,16 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
Handle<Map> string_map =
Handle<Map>(native_context()->string_function()->initial_map());
- Handle<DescriptorArray> string_descriptors(
- factory->NewDescriptorArray(0, 1));
- DescriptorArray::WhitenessWitness witness(*string_descriptors);
+ Map::EnsureDescriptorSlack(string_map, 1);
Handle<Foreign> string_length(
factory->NewForeign(&Accessors::StringLength));
PropertyAttributes attribs = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE | READ_ONLY);
- string_map->set_instance_descriptors(*string_descriptors);
{ // Add length.
CallbacksDescriptor d(factory->length_string(), string_length, attribs);
- string_map->AppendDescriptor(&d, witness);
+ string_map->AppendDescriptor(&d);
}
}
@@ -958,9 +947,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
PropertyAttributes final =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
- Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5);
- DescriptorArray::WhitenessWitness witness(*descriptors);
- initial_map->set_instance_descriptors(*descriptors);
+ Map::EnsureDescriptorSlack(initial_map, 5);
{
// ECMA-262, section 15.10.7.1.
@@ -968,7 +955,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
JSRegExp::kSourceFieldIndex,
final,
Representation::Tagged());
- initial_map->AppendDescriptor(&field, witness);
+ initial_map->AppendDescriptor(&field);
}
{
// ECMA-262, section 15.10.7.2.
@@ -976,7 +963,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
JSRegExp::kGlobalFieldIndex,
final,
Representation::Tagged());
- initial_map->AppendDescriptor(&field, witness);
+ initial_map->AppendDescriptor(&field);
}
{
// ECMA-262, section 15.10.7.3.
@@ -984,7 +971,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
JSRegExp::kIgnoreCaseFieldIndex,
final,
Representation::Tagged());
- initial_map->AppendDescriptor(&field, witness);
+ initial_map->AppendDescriptor(&field);
}
{
// ECMA-262, section 15.10.7.4.
@@ -992,7 +979,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
JSRegExp::kMultilineFieldIndex,
final,
Representation::Tagged());
- initial_map->AppendDescriptor(&field, witness);
+ initial_map->AppendDescriptor(&field);
}
{
// ECMA-262, section 15.10.7.5.
@@ -1002,7 +989,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
JSRegExp::kLastIndexFieldIndex,
writable,
Representation::Tagged());
- initial_map->AppendDescriptor(&field, witness);
+ initial_map->AppendDescriptor(&field);
}
initial_map->set_inobject_properties(5);
@@ -1175,26 +1162,24 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
Heap::kStrictArgumentsObjectSize);
// Create the descriptor array for the arguments object.
- Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
- DescriptorArray::WhitenessWitness witness(*descriptors);
- map->set_instance_descriptors(*descriptors);
+ Map::EnsureDescriptorSlack(map, 3);
{ // length
FieldDescriptor d(
factory->length_string(), 0, DONT_ENUM, Representation::Tagged());
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // callee
CallbacksDescriptor d(factory->callee_string(),
callee,
attributes);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
{ // caller
CallbacksDescriptor d(factory->caller_string(),
caller,
attributes);
- map->AppendDescriptor(&d, witness);
+ map->AppendDescriptor(&d);
}
map->set_function_with_prototype(true);
@@ -1380,11 +1365,8 @@ void Genesis::InitializeExperimentalGlobal() {
object_function, JSGeneratorObject::kResultPropertyCount);
ASSERT(generator_result_map->inobject_properties() ==
JSGeneratorObject::kResultPropertyCount);
-
- Handle<DescriptorArray> descriptors = factory()->NewDescriptorArray(0,
- JSGeneratorObject::kResultPropertyCount);
- DescriptorArray::WhitenessWitness witness(*descriptors);
- generator_result_map->set_instance_descriptors(*descriptors);
+ Map::EnsureDescriptorSlack(
+ generator_result_map, JSGeneratorObject::kResultPropertyCount);
Handle<String> value_string = factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("value"));
@@ -1392,7 +1374,7 @@ void Genesis::InitializeExperimentalGlobal() {
JSGeneratorObject::kResultValuePropertyIndex,
NONE,
Representation::Tagged());
- generator_result_map->AppendDescriptor(&value_descr, witness);
+ generator_result_map->AppendDescriptor(&value_descr);
Handle<String> done_string = factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("done"));
@@ -1400,7 +1382,7 @@ void Genesis::InitializeExperimentalGlobal() {
JSGeneratorObject::kResultDonePropertyIndex,
NONE,
Representation::Tagged());
- generator_result_map->AppendDescriptor(&done_descr, witness);
+ generator_result_map->AppendDescriptor(&done_descr);
generator_result_map->set_unused_property_fields(0);
ASSERT_EQ(JSGeneratorObject::kResultSize,
@@ -1608,20 +1590,17 @@ Handle<JSFunction> Genesis::InstallInternalArray(
array_function->set_initial_map(*initial_map);
// Make "length" magic on instances.
- Handle<DescriptorArray> array_descriptors(
- factory()->NewDescriptorArray(0, 1));
- DescriptorArray::WhitenessWitness witness(*array_descriptors);
+ Map::EnsureDescriptorSlack(initial_map, 1);
Handle<Foreign> array_length(factory()->NewForeign(
&Accessors::ArrayLength));
PropertyAttributes attribs = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE);
- initial_map->set_instance_descriptors(*array_descriptors);
{ // Add length.
CallbacksDescriptor d(
factory()->length_string(), array_length, attribs);
- array_function->initial_map()->AppendDescriptor(&d, witness);
+ array_function->initial_map()->AppendDescriptor(&d);
}
return array_function;
@@ -1702,10 +1681,7 @@ bool Genesis::InstallNatives() {
native_context()->set_script_function(*script_fun);
Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
-
- Handle<DescriptorArray> script_descriptors(
- factory()->NewDescriptorArray(0, 13));
- DescriptorArray::WhitenessWitness witness(*script_descriptors);
+ Map::EnsureDescriptorSlack(script_map, 13);
Handle<Foreign> script_source(
factory()->NewForeign(&Accessors::ScriptSource));
@@ -1757,61 +1733,60 @@ bool Genesis::InstallNatives() {
factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
PropertyAttributes attribs =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
- script_map->set_instance_descriptors(*script_descriptors);
{
CallbacksDescriptor d(
factory()->source_string(), script_source, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(factory()->name_string(), script_name, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(id_string, script_id, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(line_offset_string, script_line_offset, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(
column_offset_string, script_column_offset, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(type_string, script_type, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(
compilation_type_string, script_compilation_type, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(line_ends_string, script_line_ends, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(
context_data_string, script_context_data, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
CallbacksDescriptor d(
eval_from_script_string, script_eval_from_script, attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
@@ -1819,7 +1794,7 @@ bool Genesis::InstallNatives() {
eval_from_script_position_string,
script_eval_from_script_position,
attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
{
@@ -1827,7 +1802,7 @@ bool Genesis::InstallNatives() {
eval_from_function_name_string,
script_eval_from_function_name,
attribs);
- script_map->AppendDescriptor(&d, witness);
+ script_map->AppendDescriptor(&d);
}
// Allocate the empty script.
@@ -1947,10 +1922,7 @@ bool Genesis::InstallNatives() {
initial_map->set_prototype(*array_prototype);
// Update map with length accessor from Array and add "index" and "input".
- Handle<DescriptorArray> reresult_descriptors =
- factory()->NewDescriptorArray(0, 3);
- DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
- initial_map->set_instance_descriptors(*reresult_descriptors);
+ Map::EnsureDescriptorSlack(initial_map, 3);
{
JSFunction* array_function = native_context()->array_function();
@@ -1964,14 +1936,14 @@ bool Genesis::InstallNatives() {
handle(array_descriptors->GetValue(old),
isolate()),
array_descriptors->GetDetails(old).attributes());
- initial_map->AppendDescriptor(&desc, witness);
+ initial_map->AppendDescriptor(&desc);
}
{
FieldDescriptor index_field(factory()->index_string(),
JSRegExpResult::kIndexIndex,
NONE,
Representation::Tagged());
- initial_map->AppendDescriptor(&index_field, witness);
+ initial_map->AppendDescriptor(&index_field);
}
{
@@ -1979,7 +1951,7 @@ bool Genesis::InstallNatives() {
JSRegExpResult::kInputIndex,
NONE,
Representation::Tagged());
- initial_map->AppendDescriptor(&input_field, witness);
+ initial_map->AppendDescriptor(&input_field);
}
initial_map->set_inobject_properties(2);
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698