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