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

Unified Diff: test/cctest/test-heap.cc

Issue 23601031: Handlify JSReceiver::SetProperty and friends. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 9e4e90721c69bc84f9a92d95f951430397784fae..be511939b77db242ce5a744fba46cb27b3830665 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -262,6 +262,8 @@ TEST(GarbageCollection) {
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx");
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
+ Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
+ Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
{
HandleScope inner_scope(isolate);
@@ -271,14 +273,12 @@ TEST(GarbageCollection) {
Handle<Map> initial_map =
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
- Isolate::Current()->context()->global_object()->SetProperty(
- *name, *function, NONE, kNonStrictMode)->ToObjectChecked();
+ Handle<GlobalObject> global(Isolate::Current()->context()->global_object());
+ JSReceiver::SetProperty(global, name, function, NONE, kNonStrictMode);
// Allocate an object. Unrooted after leaving the scope.
Handle<JSObject> obj = factory->NewJSObject(function);
- obj->SetProperty(
- *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
- obj->SetProperty(
- *prop_namex, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(obj, prop_namex, twenty_four, NONE, kNonStrictMode);
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex));
@@ -299,10 +299,9 @@ TEST(GarbageCollection) {
HandleScope inner_scope(isolate);
// Allocate another object, make it reachable from global.
Handle<JSObject> obj = factory->NewJSObject(function);
- Isolate::Current()->context()->global_object()->SetProperty(
- *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked();
- obj->SetProperty(
- *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
+ Handle<GlobalObject> global(Isolate::Current()->context()->global_object());
+ JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
}
// After gc, it should survive.
@@ -628,14 +627,16 @@ TEST(FunctionAllocation) {
factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->set_initial_map(*initial_map);
+ Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
+ Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
+
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<JSObject> obj = factory->NewJSObject(function);
- obj->SetProperty(
- *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
// Check that we can add properties to function objects.
- function->SetProperty(
- *prop_name, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(function, prop_name, twenty_four, NONE,
+ kNonStrictMode);
CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name));
}
@@ -655,12 +656,14 @@ TEST(ObjectProperties) {
Handle<String> first = factory->InternalizeUtf8String("first");
Handle<String> second = factory->InternalizeUtf8String("second");
+ Handle<Smi> one(Smi::FromInt(1), isolate);
+ Handle<Smi> two(Smi::FromInt(2), isolate);
+
// check for empty
CHECK(!obj->HasLocalProperty(*first));
// add first
- obj->SetProperty(
- *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
CHECK(obj->HasLocalProperty(*first));
// delete first
@@ -668,10 +671,8 @@ TEST(ObjectProperties) {
CHECK(!obj->HasLocalProperty(*first));
// add first and then second
- obj->SetProperty(
- *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- obj->SetProperty(
- *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
CHECK(obj->HasLocalProperty(*first));
CHECK(obj->HasLocalProperty(*second));
@@ -683,10 +684,8 @@ TEST(ObjectProperties) {
CHECK(!obj->HasLocalProperty(*second));
// add first and then second
- obj->SetProperty(
- *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- obj->SetProperty(
- *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
CHECK(obj->HasLocalProperty(*first));
CHECK(obj->HasLocalProperty(*second));
@@ -700,16 +699,14 @@ TEST(ObjectProperties) {
// check string and internalized string match
const char* string1 = "fisk";
Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1));
- obj->SetProperty(
- *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, s1, one, NONE, kNonStrictMode);
Handle<String> s1_string = factory->InternalizeUtf8String(string1);
CHECK(obj->HasLocalProperty(*s1_string));
// check internalized string and string match
const char* string2 = "fugl";
Handle<String> s2_string = factory->InternalizeUtf8String(string2);
- obj->SetProperty(
- *s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode);
Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2));
CHECK(obj->HasLocalProperty(*s2));
}
@@ -732,8 +729,8 @@ TEST(JSObjectMaps) {
Handle<JSObject> obj = factory->NewJSObject(function);
// Set a propery
- obj->SetProperty(
- *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
+ Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
+ JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode);
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
// Check the map has changed
@@ -805,10 +802,11 @@ TEST(JSObjectCopy) {
Handle<String> first = factory->InternalizeUtf8String("first");
Handle<String> second = factory->InternalizeUtf8String("second");
- obj->SetProperty(
- *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
- obj->SetProperty(
- *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
+ Handle<Smi> one(Smi::FromInt(1), isolate);
+ Handle<Smi> two(Smi::FromInt(2), isolate);
+
+ JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked();
obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked();
@@ -824,10 +822,8 @@ TEST(JSObjectCopy) {
CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
// Flip the values.
- clone->SetProperty(
- *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
- clone->SetProperty(
- *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
+ JSReceiver::SetProperty(clone, first, two, NONE, kNonStrictMode);
+ JSReceiver::SetProperty(clone, second, one, NONE, kNonStrictMode);
clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked();
clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
@@ -3009,9 +3005,10 @@ TEST(Regression144230) {
// visited later, causing the CallIC to be cleared.
Handle<String> name = isolate->factory()->InternalizeUtf8String("call");
Handle<GlobalObject> global(isolate->context()->global_object());
+ Handle<Smi> zero(Smi::FromInt(0), isolate);
MaybeObject* maybe_call = global->GetProperty(*name);
JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked());
- USE(global->SetProperty(*name, Smi::FromInt(0), NONE, kNonStrictMode));
+ JSReceiver::SetProperty(global, name, zero, NONE, kNonStrictMode);
isolate->compilation_cache()->Clear();
call->shared()->set_ic_age(heap->global_ic_age() + 1);
Handle<Object> call_code(call->code(), isolate);
@@ -3022,7 +3019,7 @@ TEST(Regression144230) {
// Either heap verification caught the problem already or we go kaboom once
// the CallIC is executed the next time.
- USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
+ JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode);
CompileRun("call();");
}
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698