Clean up a couple of runtime functions that mixed handles and raw
authormads.s.ager@gmail.com <mads.s.ager@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 29 Aug 2008 08:48:06 +0000 (08:48 +0000)
committermads.s.ager@gmail.com <mads.s.ager@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 29 Aug 2008 08:48:06 +0000 (08:48 +0000)
pointers.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@36 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/handles.cc
src/handles.h
src/runtime.cc
test/mjsunit/bugs/bug-1346700.js

index a3251bf..0e8826d 100644 (file)
@@ -248,6 +248,11 @@ Handle<Object> DeleteProperty(Handle<JSObject> obj,
 }
 
 
+Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index) {
+  CALL_HEAP_FUNCTION(Heap::LookupSingleCharacterStringFromCode(index), Object);
+}
+
+
 Handle<String> SubString(Handle<String> str, int start, int end) {
   CALL_HEAP_FUNCTION(str->Slice(start, end), String);
 }
index aa5be2f..6fea67b 100644 (file)
@@ -142,6 +142,8 @@ Handle<Object> GetPrototype(Handle<Object> obj);
 Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
 Handle<Object> DeleteProperty(Handle<JSObject> obj, Handle<String> prop);
 
+Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index);
+
 Handle<JSObject> Copy(Handle<JSObject> obj, PretenureFlag = NOT_TENURED);
 
 // Get the JS object corresponding to the given script; create it
index d9d5a2d..310611c 100644 (file)
@@ -1175,31 +1175,32 @@ static Object* Runtime_NumberToPrecision(Arguments args) {
 
 // Returns a single character string where first character equals
 // string->Get(index).
-static Object* GetCharAt(String* string, uint32_t index) {
+static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
   if (index < static_cast<uint32_t>(string->length())) {
     string->TryFlatten();
-    return Heap::LookupSingleCharacterStringFromCode(string->Get(index));
+    return LookupSingleCharacterStringFromCode(string->Get(index));
   }
-  return *Execution::CharAt(Handle<String>(string), index);
+  return Execution::CharAt(string, index);
 }
 
 
 Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) {
   // Handle [] indexing on Strings
   if (object->IsString()) {
-    Object* result = GetCharAt(String::cast(*object), index);
-    if (!result->IsUndefined()) return result;
+    Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
+    if (!result->IsUndefined()) return *result;
   }
 
   // Handle [] indexing on String objects
   if (object->IsStringObjectWithCharacterAt(index)) {
-    JSValue* js_value = JSValue::cast(*object);
-    Object* result = GetCharAt(String::cast(js_value->value()), index);
-    if (!result->IsUndefined()) return result;
+    Handle<JSValue> js_value = Handle<JSValue>::cast(object);
+    Handle<Object> result =
+        GetCharAt(Handle<String>(String::cast(js_value->value())), index);
+    if (!result->IsUndefined()) return *result;
   }
 
   if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
-    Object* prototype = object->GetPrototype();
+    Handle<Object> prototype = GetPrototype(object);
     return prototype->GetElement(index);
   }
 
index b6f3f02..249ae41 100644 (file)
@@ -1,2 +1,29 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 var o = {"\u59cb\u53d1\u7ad9": 1};
 assertEquals(1, o.\u59cb\u53d1\u7ad9);