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

Side by Side Diff: src/runtime.cc

Issue 4343003: Version 2.5.4 (Closed)
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « src/runtime.h ('k') | src/scanner.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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 array->set_properties(Heap::empty_fixed_array()); 1417 array->set_properties(Heap::empty_fixed_array());
1418 array->set_elements(elements); 1418 array->set_elements(elements);
1419 array->set_length(Smi::FromInt(elements_count)); 1419 array->set_length(Smi::FromInt(elements_count));
1420 // Write in-object properties after the length of the array. 1420 // Write in-object properties after the length of the array.
1421 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); 1421 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]);
1422 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); 1422 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]);
1423 return array; 1423 return array;
1424 } 1424 }
1425 1425
1426 1426
1427 static MaybeObject* Runtime_RegExpCloneResult(Arguments args) {
1428 ASSERT(args.length() == 1);
1429 Map* regexp_result_map;
1430 {
1431 AssertNoAllocation no_gc;
1432 HandleScope handles;
1433 regexp_result_map = Top::global_context()->regexp_result_map();
1434 }
1435 if (!args[0]->IsJSArray()) return args[0];
1436
1437 JSArray* result = JSArray::cast(args[0]);
1438 // Arguments to RegExpCloneResult should always be fresh RegExp exec call
1439 // results (either a fresh JSRegExpResult or null).
1440 // If the argument is not a JSRegExpResult, or isn't unmodified, just return
1441 // the argument uncloned.
1442 if (result->map() != regexp_result_map) return result;
1443
1444 // Having the original JSRegExpResult map guarantees that we have
1445 // fast elements and no properties except the two in-object properties.
1446 ASSERT(result->HasFastElements());
1447 ASSERT(result->properties() == Heap::empty_fixed_array());
1448 ASSERT_EQ(2, regexp_result_map->inobject_properties());
1449
1450 Object* new_array_alloc;
1451 { MaybeObject* maybe_new_array_alloc =
1452 Heap::AllocateRaw(JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE);
1453 if (!maybe_new_array_alloc->ToObject(&new_array_alloc)) {
1454 return maybe_new_array_alloc;
1455 }
1456 }
1457
1458 // Set HeapObject map to JSRegExpResult map.
1459 reinterpret_cast<HeapObject*>(new_array_alloc)->set_map(regexp_result_map);
1460
1461 JSArray* new_array = JSArray::cast(new_array_alloc);
1462
1463 // Copy JSObject properties.
1464 new_array->set_properties(result->properties()); // Empty FixedArray.
1465
1466 // Copy JSObject elements as copy-on-write.
1467 FixedArray* elements = FixedArray::cast(result->elements());
1468 if (elements != Heap::empty_fixed_array()) {
1469 elements->set_map(Heap::fixed_cow_array_map());
1470 }
1471 new_array->set_elements(elements);
1472
1473 // Copy JSArray length.
1474 new_array->set_length(result->length());
1475
1476 // Copy JSRegExpResult in-object property fields input and index.
1477 new_array->FastPropertyAtPut(JSRegExpResult::kIndexIndex,
1478 result->FastPropertyAt(
1479 JSRegExpResult::kIndexIndex));
1480 new_array->FastPropertyAtPut(JSRegExpResult::kInputIndex,
1481 result->FastPropertyAt(
1482 JSRegExpResult::kInputIndex));
1483 return new_array;
1484 }
1485
1486
1487 static MaybeObject* Runtime_RegExpInitializeObject(Arguments args) { 1427 static MaybeObject* Runtime_RegExpInitializeObject(Arguments args) {
1488 AssertNoAllocation no_alloc; 1428 AssertNoAllocation no_alloc;
1489 ASSERT(args.length() == 5); 1429 ASSERT(args.length() == 5);
1490 CONVERT_CHECKED(JSRegExp, regexp, args[0]); 1430 CONVERT_CHECKED(JSRegExp, regexp, args[0]);
1491 CONVERT_CHECKED(String, source, args[1]); 1431 CONVERT_CHECKED(String, source, args[1]);
1492 1432
1493 Object* global = args[2]; 1433 Object* global = args[2];
1494 if (!global->IsTrue()) global = Heap::false_value(); 1434 if (!global->IsTrue()) global = Heap::false_value();
1495 1435
1496 Object* ignoreCase = args[3]; 1436 Object* ignoreCase = args[3];
(...skipping 7387 matching lines...) Expand 10 before | Expand all | Expand 10 after
8884 StackFrameLocator locator; 8824 StackFrameLocator locator;
8885 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 8825 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
8886 for (ScopeIterator it(frame); !it.Done(); it.Next()) { 8826 for (ScopeIterator it(frame); !it.Done(); it.Next()) {
8887 it.DebugPrint(); 8827 it.DebugPrint();
8888 } 8828 }
8889 #endif 8829 #endif
8890 return Heap::undefined_value(); 8830 return Heap::undefined_value();
8891 } 8831 }
8892 8832
8893 8833
8894 static MaybeObject* Runtime_GetCFrames(Arguments args) {
8895 // See bug 906.
8896 return Heap::undefined_value();
8897 }
8898
8899
8900 static MaybeObject* Runtime_GetThreadCount(Arguments args) { 8834 static MaybeObject* Runtime_GetThreadCount(Arguments args) {
8901 HandleScope scope; 8835 HandleScope scope;
8902 ASSERT(args.length() == 1); 8836 ASSERT(args.length() == 1);
8903 8837
8904 // Check arguments. 8838 // Check arguments.
8905 Object* result; 8839 Object* result;
8906 { MaybeObject* maybe_result = Runtime_CheckExecutionState(args); 8840 { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
8907 if (!maybe_result->ToObject(&result)) return maybe_result; 8841 if (!maybe_result->ToObject(&result)) return maybe_result;
8908 } 8842 }
8909 8843
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
10386 } else { 10320 } else {
10387 // Handle last resort GC and make sure to allow future allocations 10321 // Handle last resort GC and make sure to allow future allocations
10388 // to grow the heap without causing GCs (if possible). 10322 // to grow the heap without causing GCs (if possible).
10389 Counters::gc_last_resort_from_js.Increment(); 10323 Counters::gc_last_resort_from_js.Increment();
10390 Heap::CollectAllGarbage(false); 10324 Heap::CollectAllGarbage(false);
10391 } 10325 }
10392 } 10326 }
10393 10327
10394 10328
10395 } } // namespace v8::internal 10329 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698