| OLD | NEW |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 static void CheckFindCodeObject(Isolate* isolate) { | 110 static void CheckFindCodeObject(Isolate* isolate) { |
| 111 // Test FindCodeObject | 111 // Test FindCodeObject |
| 112 #define __ assm. | 112 #define __ assm. |
| 113 | 113 |
| 114 Assembler assm(isolate, NULL, 0); | 114 Assembler assm(isolate, NULL, 0); |
| 115 | 115 |
| 116 __ nop(); // supported on all architectures | 116 __ nop(); // supported on all architectures |
| 117 | 117 |
| 118 CodeDesc desc; | 118 CodeDesc desc; |
| 119 assm.GetCode(&desc); | 119 assm.GetCode(&desc); |
| 120 Heap* heap = isolate->heap(); | 120 Handle<Code> code = isolate->factory()->NewCode( |
| 121 Object* code = heap->CreateCode( | 121 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 122 desc, | |
| 123 Code::ComputeFlags(Code::STUB), | |
| 124 Handle<Code>())->ToObjectChecked(); | |
| 125 CHECK(code->IsCode()); | 122 CHECK(code->IsCode()); |
| 126 | 123 |
| 127 HeapObject* obj = HeapObject::cast(code); | 124 HeapObject* obj = HeapObject::cast(*code); |
| 128 Address obj_addr = obj->address(); | 125 Address obj_addr = obj->address(); |
| 129 | 126 |
| 130 for (int i = 0; i < obj->Size(); i += kPointerSize) { | 127 for (int i = 0; i < obj->Size(); i += kPointerSize) { |
| 131 Object* found = isolate->FindCodeObject(obj_addr + i); | 128 Object* found = isolate->FindCodeObject(obj_addr + i); |
| 132 CHECK_EQ(code, found); | 129 CHECK_EQ(*code, found); |
| 133 } | 130 } |
| 134 | 131 |
| 135 Object* copy = heap->CreateCode( | 132 Handle<Code> copy = isolate->factory()->NewCode( |
| 136 desc, | 133 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 137 Code::ComputeFlags(Code::STUB), | 134 HeapObject* obj_copy = HeapObject::cast(*copy); |
| 138 Handle<Code>())->ToObjectChecked(); | |
| 139 CHECK(copy->IsCode()); | |
| 140 HeapObject* obj_copy = HeapObject::cast(copy); | |
| 141 Object* not_right = isolate->FindCodeObject(obj_copy->address() + | 135 Object* not_right = isolate->FindCodeObject(obj_copy->address() + |
| 142 obj_copy->Size() / 2); | 136 obj_copy->Size() / 2); |
| 143 CHECK(not_right != code); | 137 CHECK(not_right != *code); |
| 144 } | 138 } |
| 145 | 139 |
| 146 | 140 |
| 147 TEST(HandleNull) { | 141 TEST(HandleNull) { |
| 148 CcTest::InitializeVM(); | 142 CcTest::InitializeVM(); |
| 149 Isolate* isolate = CcTest::i_isolate(); | 143 Isolate* isolate = CcTest::i_isolate(); |
| 150 HandleScope outer_scope(isolate); | 144 HandleScope outer_scope(isolate); |
| 151 LocalContext context; | 145 LocalContext context; |
| 152 Handle<Object> n(reinterpret_cast<Object*>(NULL), isolate); | 146 Handle<Object> n(reinterpret_cast<Object*>(NULL), isolate); |
| 153 CHECK(!n.is_null()); | 147 CHECK(!n.is_null()); |
| (...skipping 4034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4188 v8::Context::Scope cscope(context); | 4182 v8::Context::Scope cscope(context); |
| 4189 | 4183 |
| 4190 v8::Local<v8::Value> result = CompileRun( | 4184 v8::Local<v8::Value> result = CompileRun( |
| 4191 "var locals = '';" | 4185 "var locals = '';" |
| 4192 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" | 4186 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" |
| 4193 "eval('function f() {' + locals + 'return function() { return v0; }; }');" | 4187 "eval('function f() {' + locals + 'return function() { return v0; }; }');" |
| 4194 "interrupt();" // This triggers a fake stack overflow in f. | 4188 "interrupt();" // This triggers a fake stack overflow in f. |
| 4195 "f()()"); | 4189 "f()()"); |
| 4196 CHECK_EQ(42.0, result->ToNumber()->Value()); | 4190 CHECK_EQ(42.0, result->ToNumber()->Value()); |
| 4197 } | 4191 } |
| OLD | NEW |