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

Side by Side Diff: src/runtime.cc

Issue 10392150: Remove %_SwapElements. This inlined runtime contained an optimization that was dangerous in the pr… (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 7 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/runtime.h ('k') | src/x64/full-codegen-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 10008 matching lines...) Expand 10 before | Expand all | Expand 10 after
10019 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); 10019 int result = SeededNumberDictionary::cast(elements)->NumberOfElements();
10020 return Smi::FromInt(result); 10020 return Smi::FromInt(result);
10021 } else if (object->IsJSArray()) { 10021 } else if (object->IsJSArray()) {
10022 return JSArray::cast(object)->length(); 10022 return JSArray::cast(object)->length();
10023 } else { 10023 } else {
10024 return Smi::FromInt(FixedArray::cast(elements)->length()); 10024 return Smi::FromInt(FixedArray::cast(elements)->length());
10025 } 10025 }
10026 } 10026 }
10027 10027
10028 10028
10029 RUNTIME_FUNCTION(MaybeObject*, Runtime_SwapElements) {
10030 HandleScope handle_scope(isolate);
10031
10032 ASSERT_EQ(3, args.length());
10033
10034 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
10035 Handle<Object> key1 = args.at<Object>(1);
10036 Handle<Object> key2 = args.at<Object>(2);
10037
10038 uint32_t index1, index2;
10039 if (!key1->ToArrayIndex(&index1)
10040 || !key2->ToArrayIndex(&index2)) {
10041 return isolate->ThrowIllegalOperation();
10042 }
10043
10044 Handle<JSObject> jsobject = Handle<JSObject>::cast(object);
10045 Handle<Object> tmp1 = Object::GetElement(jsobject, index1);
10046 RETURN_IF_EMPTY_HANDLE(isolate, tmp1);
10047 Handle<Object> tmp2 = Object::GetElement(jsobject, index2);
10048 RETURN_IF_EMPTY_HANDLE(isolate, tmp2);
10049
10050 RETURN_IF_EMPTY_HANDLE(
10051 isolate, JSObject::SetElement(jsobject, index1, tmp2, NONE, kStrictMode));
10052 RETURN_IF_EMPTY_HANDLE(
10053 isolate, JSObject::SetElement(jsobject, index2, tmp1, NONE, kStrictMode));
10054
10055 return isolate->heap()->undefined_value();
10056 }
10057
10058
10059 // Returns an array that tells you where in the [0, length) interval an array 10029 // Returns an array that tells you where in the [0, length) interval an array
10060 // might have elements. Can either return keys (positive integers) or 10030 // might have elements. Can either return keys (positive integers) or
10061 // intervals (pair of a negative integer (-start-1) followed by a 10031 // intervals (pair of a negative integer (-start-1) followed by a
10062 // positive (length)) or undefined values. 10032 // positive (length)) or undefined values.
10063 // Intervals can span over some keys that are not in the object. 10033 // Intervals can span over some keys that are not in the object.
10064 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { 10034 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
10065 ASSERT(args.length() == 2); 10035 ASSERT(args.length() == 2);
10066 HandleScope scope(isolate); 10036 HandleScope scope(isolate);
10067 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 10037 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
10068 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); 10038 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
(...skipping 3436 matching lines...) Expand 10 before | Expand all | Expand 10 after
13505 // Handle last resort GC and make sure to allow future allocations 13475 // Handle last resort GC and make sure to allow future allocations
13506 // to grow the heap without causing GCs (if possible). 13476 // to grow the heap without causing GCs (if possible).
13507 isolate->counters()->gc_last_resort_from_js()->Increment(); 13477 isolate->counters()->gc_last_resort_from_js()->Increment();
13508 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13478 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13509 "Runtime::PerformGC"); 13479 "Runtime::PerformGC");
13510 } 13480 }
13511 } 13481 }
13512 13482
13513 13483
13514 } } // namespace v8::internal 13484 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698