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

Side by Side Diff: src/factory.cc

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | « src/factory.h ('k') | src/flag-definitions.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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 253
254 Handle<String> Factory::NewConsString(Handle<String> first, 254 Handle<String> Factory::NewConsString(Handle<String> first,
255 Handle<String> second) { 255 Handle<String> second) {
256 CALL_HEAP_FUNCTION(isolate(), 256 CALL_HEAP_FUNCTION(isolate(),
257 isolate()->heap()->AllocateConsString(*first, *second), 257 isolate()->heap()->AllocateConsString(*first, *second),
258 String); 258 String);
259 } 259 }
260 260
261 261
262 template<typename SinkChar, typename StringType>
263 Handle<String> ConcatStringContent(Handle<StringType> result,
264 Handle<String> first,
265 Handle<String> second) {
266 DisallowHeapAllocation pointer_stays_valid;
267 SinkChar* sink = result->GetChars();
268 String::WriteToFlat(*first, sink, 0, first->length());
269 String::WriteToFlat(*second, sink + first->length(), 0, second->length());
270 return result;
271 }
272
273
274 Handle<String> Factory::NewFlatConcatString(Handle<String> first,
275 Handle<String> second) {
276 int total_length = first->length() + second->length();
277 if (first->IsOneByteRepresentationUnderneath() &&
278 second->IsOneByteRepresentationUnderneath()) {
279 return ConcatStringContent<uint8_t>(
280 NewRawOneByteString(total_length), first, second);
281 } else {
282 return ConcatStringContent<uc16>(
283 NewRawTwoByteString(total_length), first, second);
284 }
285 }
286
287
262 Handle<String> Factory::NewSubString(Handle<String> str, 288 Handle<String> Factory::NewSubString(Handle<String> str,
263 int begin, 289 int begin,
264 int end) { 290 int end) {
265 CALL_HEAP_FUNCTION(isolate(), 291 CALL_HEAP_FUNCTION(isolate(),
266 str->SubString(begin, end), 292 str->SubString(begin, end),
267 String); 293 String);
268 } 294 }
269 295
270 296
271 Handle<String> Factory::NewProperSubString(Handle<String> str, 297 Handle<String> Factory::NewProperSubString(Handle<String> str,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 Handle<ExecutableAccessorInfo> info = 427 Handle<ExecutableAccessorInfo> info =
402 Handle<ExecutableAccessorInfo>::cast( 428 Handle<ExecutableAccessorInfo>::cast(
403 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE)); 429 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE));
404 info->set_flag(0); // Must clear the flag, it was initialized as undefined. 430 info->set_flag(0); // Must clear the flag, it was initialized as undefined.
405 return info; 431 return info;
406 } 432 }
407 433
408 434
409 Handle<Script> Factory::NewScript(Handle<String> source) { 435 Handle<Script> Factory::NewScript(Handle<String> source) {
410 // Generate id for this script. 436 // Generate id for this script.
411 int id;
412 Heap* heap = isolate()->heap(); 437 Heap* heap = isolate()->heap();
413 if (heap->last_script_id()->IsUndefined()) { 438 int id = heap->last_script_id()->value() + 1;
414 // Script ids start from one. 439 if (!Smi::IsValid(id) || id < 0) id = 1;
415 id = 1; 440 heap->set_last_script_id(Smi::FromInt(id));
416 } else {
417 // Increment id, wrap when positive smi is exhausted.
418 id = Smi::cast(heap->last_script_id())->value();
419 id++;
420 if (!Smi::IsValid(id)) {
421 id = 0;
422 }
423 }
424 heap->SetLastScriptId(Smi::FromInt(id));
425 441
426 // Create and initialize script object. 442 // Create and initialize script object.
427 Handle<Foreign> wrapper = NewForeign(0, TENURED); 443 Handle<Foreign> wrapper = NewForeign(0, TENURED);
428 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); 444 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
429 script->set_source(*source); 445 script->set_source(*source);
430 script->set_name(heap->undefined_value()); 446 script->set_name(heap->undefined_value());
431 script->set_id(heap->last_script_id()); 447 script->set_id(Smi::FromInt(id));
432 script->set_line_offset(Smi::FromInt(0)); 448 script->set_line_offset(Smi::FromInt(0));
433 script->set_column_offset(Smi::FromInt(0)); 449 script->set_column_offset(Smi::FromInt(0));
434 script->set_data(heap->undefined_value()); 450 script->set_data(heap->undefined_value());
435 script->set_context_data(heap->undefined_value()); 451 script->set_context_data(heap->undefined_value());
436 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); 452 script->set_type(Smi::FromInt(Script::TYPE_NORMAL));
437 script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST)); 453 script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST));
438 script->set_compilation_state( 454 script->set_compilation_state(
439 Smi::FromInt(Script::COMPILATION_STATE_INITIAL)); 455 Smi::FromInt(Script::COMPILATION_STATE_INITIAL));
440 script->set_wrapper(*wrapper); 456 script->set_wrapper(*wrapper);
441 script->set_line_ends(heap->undefined_value()); 457 script->set_line_ends(heap->undefined_value());
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { 1089 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
1074 JSFunction* array_buffer_fun = 1090 JSFunction* array_buffer_fun =
1075 isolate()->context()->native_context()->array_buffer_fun(); 1091 isolate()->context()->native_context()->array_buffer_fun();
1076 CALL_HEAP_FUNCTION( 1092 CALL_HEAP_FUNCTION(
1077 isolate(), 1093 isolate(),
1078 isolate()->heap()->AllocateJSObject(array_buffer_fun), 1094 isolate()->heap()->AllocateJSObject(array_buffer_fun),
1079 JSArrayBuffer); 1095 JSArrayBuffer);
1080 } 1096 }
1081 1097
1082 1098
1099 Handle<JSDataView> Factory::NewJSDataView() {
1100 JSFunction* data_view_fun =
1101 isolate()->context()->native_context()->data_view_fun();
1102 CALL_HEAP_FUNCTION(
1103 isolate(),
1104 isolate()->heap()->AllocateJSObject(data_view_fun),
1105 JSDataView);
1106 }
1107
1108
1083 Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) { 1109 Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
1084 JSFunction* typed_array_fun; 1110 JSFunction* typed_array_fun;
1085 Context* native_context = isolate()->context()->native_context(); 1111 Context* native_context = isolate()->context()->native_context();
1086 switch (type) { 1112 switch (type) {
1087 case kExternalUnsignedByteArray: 1113 case kExternalUnsignedByteArray:
1088 typed_array_fun = native_context->uint8_array_fun(); 1114 typed_array_fun = native_context->uint8_array_fun();
1089 break; 1115 break;
1090 1116
1091 case kExternalByteArray: 1117 case kExternalByteArray:
1092 typed_array_fun = native_context->int8_array_fun(); 1118 typed_array_fun = native_context->int8_array_fun();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 return Handle<Object>::null(); 1598 return Handle<Object>::null();
1573 } 1599 }
1574 1600
1575 1601
1576 Handle<Object> Factory::ToBoolean(bool value) { 1602 Handle<Object> Factory::ToBoolean(bool value) {
1577 return value ? true_value() : false_value(); 1603 return value ? true_value() : false_value();
1578 } 1604 }
1579 1605
1580 1606
1581 } } // namespace v8::internal 1607 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698