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

Side by Side Diff: src/factory.cc

Issue 22681004: Instance-type-related fixes and cleanup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased. Created 7 years, 4 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/objects.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1386
1387 int internal_field_count = 0; 1387 int internal_field_count = 0;
1388 if (!obj->instance_template()->IsUndefined()) { 1388 if (!obj->instance_template()->IsUndefined()) {
1389 Handle<ObjectTemplateInfo> instance_template = 1389 Handle<ObjectTemplateInfo> instance_template =
1390 Handle<ObjectTemplateInfo>( 1390 Handle<ObjectTemplateInfo>(
1391 ObjectTemplateInfo::cast(obj->instance_template())); 1391 ObjectTemplateInfo::cast(obj->instance_template()));
1392 internal_field_count = 1392 internal_field_count =
1393 Smi::cast(instance_template->internal_field_count())->value(); 1393 Smi::cast(instance_template->internal_field_count())->value();
1394 } 1394 }
1395 1395
1396 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing
1397 // JSObject::GetHeaderSize.
1396 int instance_size = kPointerSize * internal_field_count; 1398 int instance_size = kPointerSize * internal_field_count;
1397 InstanceType type = INVALID_TYPE; 1399 InstanceType type;
1398 switch (instance_type) { 1400 switch (instance_type) {
1399 case JavaScriptObject: 1401 case JavaScriptObject:
1400 type = JS_OBJECT_TYPE; 1402 type = JS_OBJECT_TYPE;
1401 instance_size += JSObject::kHeaderSize; 1403 instance_size += JSObject::kHeaderSize;
1402 break; 1404 break;
1403 case InnerGlobalObject: 1405 case InnerGlobalObject:
1404 type = JS_GLOBAL_OBJECT_TYPE; 1406 type = JS_GLOBAL_OBJECT_TYPE;
1405 instance_size += JSGlobalObject::kSize; 1407 instance_size += JSGlobalObject::kSize;
1406 break; 1408 break;
1407 case OuterGlobalObject: 1409 case OuterGlobalObject:
1408 type = JS_GLOBAL_PROXY_TYPE; 1410 type = JS_GLOBAL_PROXY_TYPE;
1409 instance_size += JSGlobalProxy::kSize; 1411 instance_size += JSGlobalProxy::kSize;
1410 break; 1412 break;
1411 default: 1413 default:
1414 UNREACHABLE();
1415 type = JS_OBJECT_TYPE; // Keep the compiler happy.
1412 break; 1416 break;
1413 } 1417 }
1414 ASSERT(type != INVALID_TYPE);
1415 1418
1416 Handle<JSFunction> result = 1419 Handle<JSFunction> result =
1417 NewFunction(Factory::empty_string(), 1420 NewFunction(Factory::empty_string(),
1418 type, 1421 type,
1419 instance_size, 1422 instance_size,
1420 code, 1423 code,
1421 true); 1424 true);
1422 1425
1423 // Set length. 1426 // Set length.
1424 result->shared()->set_length(obj->length()); 1427 result->shared()->set_length(obj->length());
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 return Handle<Object>::null(); 1610 return Handle<Object>::null();
1608 } 1611 }
1609 1612
1610 1613
1611 Handle<Object> Factory::ToBoolean(bool value) { 1614 Handle<Object> Factory::ToBoolean(bool value) {
1612 return value ? true_value() : false_value(); 1615 return value ? true_value() : false_value();
1613 } 1616 }
1614 1617
1615 1618
1616 } } // namespace v8::internal 1619 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698